java自定义布局高度包装内容,而不是使用定义的布局高度
我有一个自定义警报。根元素为LinearLayout
和安卓:layout_height="130dp"
的xml布局。我正在使用AlertDialog.Builder
来创建它
以下是我的完整XML代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:layout_height="130dp"
安卓:layout_width="wrap_content"
安卓:orientation="vertical">
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:textSize="18sp"
安卓:gravity="center"
安卓:layout_gravity="center"
安卓:text="@string/avail"/>
<View
安卓:layout_width="match_parent"
安卓:layout_height="1dp"
安卓:background="?安卓:attr/listDivider" />
<ScrollView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_gravity="center">
<LinearLayout
安卓:orientation="vertical"
安卓:paddingLeft="20dp"
安卓:paddingRight="20dp"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content">
<LinearLayout
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:orientation="horizontal"
安卓:layout_gravity="center">
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:text="@string/example" />
<ToggleButton
安卓:id="@+id/Ex"
安卓:textOn="@string/installed"
安卓:textOff="@string/uninstalled"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
style="?安卓:attr/buttonBarButtonStyle"/>
</LinearLayout>
<LinearLayout
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:orientation="horizontal"
安卓:layout_gravity="center">
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:text="@string/example" />
<ToggleButton
安卓:id="@+id/tbEx1"
安卓:textOn="@string/installed"
安卓:textOff="@string/uninstalled"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:enabled="false"
style="?安卓:attr/buttonBarButtonStyle"/>
</LinearLayout>
<LinearLayout
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:orientation="horizontal"
安卓:layout_gravity="center">
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:text="@string/example" />
<ToggleButton
安卓:id="@+id/tbEx2"
安卓:textOn="@string/installed"
安卓:textOff="@string/uninstalled"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:enabled="false"
style="?安卓:attr/buttonBarButtonStyle"/>
</LinearLayout>
<LinearLayout
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:orientation="horizontal"
安卓:layout_gravity="center">
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:text="@string/example" />
<ToggleButton
安卓:id="@+id/tbEx3"
安卓:textOn="@string/installed"
安卓:textOff="@string/uninstalled"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:enabled="false"
style="?安卓:attr/buttonBarButtonStyle"/>
</LinearLayout>
<LinearLayout
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:orientation="horizontal"
安卓:layout_gravity="center">
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:text="@string/example" />
<ToggleButton
安卓:id="@+id/tbEx4"
安卓:textOn="@string/installed"
安卓:textOff="@string/uninstalled"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:enabled="false"
style="?安卓:attr/buttonBarButtonStyle"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
如上所述,根元素设置为130dp
,但当它显示在屏幕上时,它会包装内容,当我希望它处于特定高度时,这样我就可以使用ScrollView
滚动条目
共 (0) 个答案