我想要实现的目标是:
但我拥有的是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="290dp"
android:layout_height="490dp"
android:layout_marginLeft="35dp"
android:layout_marginTop="40dp"
android:background="#2a873e"
tools:context="com.sumo.traffic.PlacesFilters"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/button3"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Button" />
<Button
android:id="@+id/button4"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:text="Button" />
</LinearLayout>
</LinearLayout>
应用滚动视图时,它显示滚动视图只能承载一个布局。 是否有另一种可能的方式来产生我想要实现的目标?
我在一个活动中放了10个以上的按钮,这就是我在布局中需要滚动视图的原因。
答案 0 :(得分:1)
尝试这种方式:
void**
答案 1 :(得分:0)
尝试使用它:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/button3"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Button" />
<Button
android:id="@+id/button4"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:text="Button" />
</LinearLayout>
</LinearLayout>
</ScrollView></LinearLayout>