简体   繁体   中英

How to align dynamically created Linear Layout to right of its parent?

I am trying to align dynamically created Linear layout to right of its parent which is a ListView. The code of list view is

<LinearLayout
        android:id="@+id/mychatlinear"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_weight="7"
        android:orientation="horizontal"
        android:padding="5dp" >

        <ListView
            android:id="@+id/chatmainlist"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:divider="@color/ripple_material_dark"
            android:dividerHeight="5dp"
            android:padding="5dp"

            tools:listitem="@layout/chatrecieve" >
        </ListView>
    </LinearLayout>

Now in the inner class extending the BaseAdapter i have used

arg1 = getLayoutInflater().inflate(R.layout.chatitem, null); 



LinearLayout layout = (LinearLayout) arg1;

This layout is aligned to the left in the list view. I want it to aligned to right. Please suggest some solution. Thanks

chatitem.xml更改LinearLayout添加android:gravity="right"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM