问题
I have this XML.I want to include dynamic buttons in the linearlayoutUp of the XML code with the Java code, and I want that this buttons appear in horizontal position, any idea to hanged vertical to horizontal
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFCCCCCC"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/linearlayoutUp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" >
</ScrollView>
</LinearLayout>
<com.example.nuevo.ControladorView
android:id="@+id/drawing"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_marginBottom="3dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="3dp"
android:layout_weight="0.83" />
<LinearLayout
android:id="@+id/linearlayoutDown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
回答1:
If you want to use a ScrollView, you put it around the Layout. Also, you should use a HorizontalScrollView since your list is horizontal.
Try this:
<HorizontalScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/linearlayoutUp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
</HorizontalScrollView>
来源:https://stackoverflow.com/questions/21995038/changed-position-buttons-in-dynamic-layout