changed position buttons in dynamic layout

两盒软妹~` 提交于 2019-12-11 18:55:22

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!