开发者

Android : center 3 TextView on the same line

I think my question 开发者_开发知识库must be really stupid, but I just spent one hour seeking on network without result ...

I have a linear Layout with 3 TextView, and I want them to share to whole width of the screen

Here is a picture to illustrate !

http://img845.imageshack.us/i/putaindlayout.png/

I'd like to have each textview just behind images ...

Thanks ...


Use weight attribute. Set weight 1 to all your TextFields and they will take all the space. Something like this should work.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android">
    <TextView
        android:layout_width="wrap_content" 
        android:id="@+id/textView1"
        android:layout_height="wrap_content" 
        android:text="TextView"
        android:gravity="center_horizontal" 
        android:layout_weight="1" />
    <TextView 
        android:layout_width="wrap_content" 
        android:id="@+id/textView2"
        android:layout_height="wrap_content" 
        android:text="TextView"
        android:gravity="center_horizontal" 
        android:layout_weight="1" />
    <TextView 
        android:layout_width="wrap_content" 
        android:id="@+id/textView3"
        android:layout_height="wrap_content" 
        android:text="TextView"
        android:gravity="center_horizontal" 
        android:layout_weight="1" />
</LinearLayout>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜