gpt4 book ai didi

java - TextView 在应用程序中不可点击

转载 作者:太空狗 更新时间:2023-10-29 16:34:33 25 4
gpt4 key购买 nike

我正在设计一个弹出式 AlertDialog,它将警报对话框的 View 设置为以下 XML 文件。由于某种原因,该文件不会添加边距,我无法弄清楚我做错了什么。 Margins 和 Padding 在 activity_priority_level_values LinearLayout、包含所有 TextView 的 LinearLayout 或任何 TextView 中不起作用。如何为对话框边框和所有 TextView 之间的边距添加边距(或填充)?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_priority_level_values"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/large_space">
<TextView android:id="@+id/level_1_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/level_1_header"/>

<TextView android:id="@+id/level_1_decription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/level_1_description"/>

<TextView android:id="@+id/level_2_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/level_2_header"/>

<TextView android:id="@+id/level_2_decription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/mid_space"
android:text="@string/level_2_description"/>

<TextView android:id="@+id/level_3_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/level_3_header"/>

<TextView android:id="@+id/level_3_decription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/mid_space"
android:text="@string/level_3_description"/>

<TextView android:id="@+id/level_4_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/level_4_header"/>

<TextView android:id="@+id/level_4_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/mid_space"
android:text="@string/level_4_description"/>

<TextView android:id="@+id/level_5_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/level_5_header"/>

<TextView android:id="@+id/level_5_decription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/level_5_description"/>
</LinearLayout>
</LinearLayout>

Activity

LinearLayout hiddenLayout = (LinearLayout)findViewById(R.id.activity_priority_level_values);
AlertDialog.Builder builder = new AlertDialog.Builder(this);

if(hiddenLayout == null){
LinearLayout myLayout = (LinearLayout)findViewById(R.id.activity_law_priority);
View hiddenInfo = getLayoutInflater().inflate(R.layout.activity_priority_level_values, null);
builder.setView(hiddenInfo);
}
builder.create();
builder.show();

最佳答案

问题是你的观点膨胀了。

LinearLayout myLayout = (LinearLayout)findViewById(R.id.activity_law_priority);
View hiddenInfo = getLayoutInflater().inflate(R.layout.activity_priority_level_values, null);

你永远不应该用 null 膨胀。而是将代码更改为:

LinearLayout myLayout = (LinearLayout)findViewById(R.id.activity_law_priority);
View hiddenInfo = getLayoutInflater().inflate(R.layout.activity_priority_level_values, myLayout, false);

如果您使用 null 进行膨胀,布局参数将被忽略。

关于java - TextView 在应用程序中不可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32003479/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com