开发者

android layout alignment textview and button

开发者 https://www.devze.com 2023-04-11 23:28 出处:网络
I have attached the contents of an xml file. What I want to do is put the TextView in the center of the Row and the button aligned from the right. I have tried 开发者_如何学Cseveral solutions and yet

I have attached the contents of an xml file. What I want to do is put the TextView in the center of the Row and the button aligned from the right. I have tried 开发者_如何学Cseveral solutions and yet I still haven't found the correct one. Any suggestions?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:stretchColumns="*">
        <TextView
            android:id="@+id/serviceTitle"
            android:textSize="20px"
            android:textStyle="bold"
            android:gravity="center_horizontal"/>
        <Button 
            android:layout_gravity="center_horizontal"
            android:id="@+id/testButton"
            android:background="@drawable/go_button">
        </Button>
    </TableRow>
    <ListView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" 
        android:id="@android:id/list">
     </ListView>
     <TextView android:id="@android:id/empty"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="Empty set"/>
</LinearLayout>


This the things you want?

    <RelativeLayout android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
        android:id="@+id/serviceTitle"
        android:textSize="20px"
        android:textStyle="bold"
        android:text="text view"
        android:layout_centerHorizontal="true"/>
    <Button 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/testButton"
        android:text="Button"
        android:layout_alignParentRight="true">
    </Button>
    </RelativeLayout>
<ListView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1" 
    android:id="@android:id/list">
 </ListView>
 <TextView android:id="@android:id/empty"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="Empty set"/>

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号