2012-04-28 28 views
0

ここに私のlayout.xmlファイルImageViewとTextViewの中央に配置するにはどうすればいいですか?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <ImageView 
     android:id="@+id/image1" 
     android:layout_width="60dp" 
     android:layout_height="60dp" 
     android:contentDescription="@string/desc" 
     android:padding="10dp" 
     android:layout_alignParentLeft="true"/> 

    <TextView 
     android:id="@+id/text1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textColor="#FFF" 
     android:layout_toRightOf="@+id/image1"/> 

    <ScrollView 
     android:id="@+id/scroll" 
     android:layout_width="wrap_content" 
     android:layout_below="@+id/text1" 
     android:layout_height="40dp"/> 

    <ImageView 
     android:id="@+id/image2" 
     android:layout_width="60dp" 
     android:layout_height="60dp" 
     android:contentDescription="@string/desc" 
     android:padding="10dp" 
     android:layout_below="@+id/image1"/> 

    <TextView 
     android:id="@+id/text2" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textColor="#FFF" 
     android:layout_below="@+id/image1" 
     android:layout_toRightOf="@+id/image2"/> 


</RelativeLayout> 

私はそれ以上のImageViewのでのTextViewを中心にしたいです。これはどうすればいいですか?

私はこのようにすることにしたい:

<Player_Image> <Player_Name_Points> 
<Player_Image> <Player_Name_Points> 
+0

2つのイメージビューと2つのテキストビューがあります。 –

+0

また、Eclipseからスクリーンショットを作成することもできます(DDMS、デバイスの下にアイコンがあります) –

答えて

2

enter image description here

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" > 

    <ImageButton 
     android:id="@+id/imageButton1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/ic_launcher" /> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="24dp" 
     android:text="TextView" /> 

</RelativeLayout> 

これをやって試してみてください...私はあなたが欲しいものをそれを得ると思います。

0

代わりScrollViewの(他のレイアウトが動作します)LinearLayout内の画像やテキストを含むカスタムアイテムでListViewを使用しています。幅にはwrap_contentを使用し、重力にはcenterを使用してください。

アダプタをバインドします。 ArrayAdapterからListViewに移動し、表示されているデータを制御します。

関連する問題