2014-09-22 15 views
0

我有以下佈局片段:Android View中的中心控件..如何?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="?android:attr/listPreferredItemHeight" 
    android:orientation="horizontal" 
    android:paddingLeft="5dip" 
    android:paddingRight="5dip" 
    android:background="#ffffff" 
    android:id="@+id/dateItemRow" 


    > 

    <TextView 
     android:id="@+id/timeField" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 

     android:gravity="center" 
     android:textStyle="bold" 
     android:layout_marginTop="3dp" 
     android:paddingBottom="0dp" 
     android:textColor="#5d6265" 

     android:textSize="16sp" /> 

    <LinearLayout 
     android:id="@+id/rowBackground" 
     android:layout_width="3dp" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:background="#33b5e6" 

     > 

     <TextView 
      android:id="@+id/seperator" 
      android:layout_width="2dp" 
      android:layout_height="fill_parent" 
      android:textColor="#000000" 
      android:text="" 
      /> 

    </LinearLayout> 

    <CheckBox 
     android:id="@+id/mycheckBox" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="15dp" 
     android:button="@drawable/custom_checkbox_design"   
     /> 

</LinearLayout> 

你如何(希望)看到這是一個佈局,其中在左派網站是一個時間字段,然後善待TimeField從複選框分離邊界。我正在尋找的是將它們全部設置爲中心。 實際的一切都在左邊的網站上。 這一切都是在什麼我有這樣的描述一個ListView:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#e8e8e8" > 
    android:orientation="vertical" > 

    <ListView 
     android:id="@+id/listView1" 
     android:layout_width="fill_parent"   
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:background="#e8e8e8" > 
    </ListView> 
</LinearLayout> 

我真的不知道我怎麼能得到這個。 THX爲您的幫助!

回答

0

嘗試增加

android:gravity="center" 

您在外的LinearLayout。

+0

不幸的是,這不是什麼幫助... :-( – Howard 2014-09-23 07:09:57

相關問題