2016-09-28 5 views
0

私は画像ビューとスクロールビュー内のすべての右側に直接2列のテキストビューを持つアンドロイドレイアウトを作成しようとしています。Q:複数のTextViewが隣接しているAndroid Imagview

ユーザーのプロフィール写真と基本情報のレイアウトのように考える。

私は達成しようとしているワイヤーフレームを作成しましたが、残念ながら私はimageviewのレイアウトを得ることができません - textview - textview correct。

他にも私が行ったことがあります。

enter image description here

EDIT これは、私は運なしで試してみましたものです:ImageViewと2 LinearLayout

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:scrollbars="none" 
    android:layout_weight="1"> 
    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:weightSum="1" 
     android:orientation="horizontal"> 
     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:weight="0.4" 
      android:src="@drawable/profileImg" /> 
     <LinearLayout 
      android:weight="0.6" 
      android:layout_width="wrap_content" 
      android:layout_height="0dp" 
      android:weightSum="1" 
      android:orientation="vertical"> 
      <RelativeLayout 
       android:weight="0.25"> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textSize="10sp" 
        android:text="User ID" 
        android:textColor="#fff" /> 
       <TextView 
        android:id="@+id/pUID" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textSize="10sp" 
        android:text="pUID" 
        android:textColor="#fff" /> 
      </RelativeLayout> 
      <RelativeLayout 
       android:weight="0.25"> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textSize="10sp" 
        android:text="Full Name" 
        android:textColor="#fff" /> 
       <TextView 
        android:id="@+id/fName" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textSize="10sp" 
        android:text="fName" 
        android:textColor="#fff" /> 
      </RelativeLayout> 
      <RelativeLayout 
       android:weight="0.25"> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textSize="10sp" 
        android:text="Age" 
        android:textColor="#fff" /> 
       <TextView 
        android:id="@+id/pAge" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textSize="10sp" 
        android:text="pAge" 
        android:textColor="#fff" /> 
      </RelativeLayout> 
      <RelativeLayout 
       android:weight="0.25"> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textSize="10sp" 
        android:text="Date of Birth" 
        android:textColor="#fff" /> 
       <TextView 
        android:id="@+id/pDOB" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textSize="10sp" 
        android:text="pDOB" 
        android:textColor="#fff" /> 
      </RelativeLayout> 
     </LinearLayout> 
    </LinearLayout> 
</ScrollView> 
+0

あなたのXMLコードを表示します。 –

+0

何かを表示...あなたのXMLファイルなどを投稿してください... – Aspicas

+0

@Aspicas私はいくつかのaxmlを追加しました – jaymarvels

答えて

1

は、次のXML fileを使用してみてください:

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

    <ScrollView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:scrollbars="none"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <LinearLayout 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:gravity="center_vertical|center_horizontal" 
       android:layout_marginTop="20dp" 
       android:layout_marginBottom="20dp"> 

       <TextView 
        android:text="TextView" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/textView48" 
        android:textSize="24sp"/> 
      </LinearLayout> 

      <LinearLayout 
       android:weight="0.6" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="horizontal"> 

       <LinearLayout 
        android:orientation="horizontal" 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.30"> 

        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:weight="0.4" 
         android:src="@drawable/profileImg" 
         android:layout_marginLeft="10dp"/> 
       </LinearLayout> 

       <LinearLayout 
        android:weight="0.25" 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="0.70"> 

        <LinearLayout 
         android:orientation="vertical" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:layout_weight="1"> 

         <LinearLayout 
          android:weight="0.25" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:layout_weight="1" 
          android:layout_marginLeft="10dp"> 
          <TextView 
           android:layout_width="match_parent" 
           android:layout_height="match_parent" 
           android:text="TextView" 
           android:textColor="#000" 
           android:textSize="24sp"/> 
         </LinearLayout> 

         <LinearLayout 
          android:weight="0.25" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:layout_weight="1" 
          android:layout_marginLeft="10dp"> 
          <TextView 
           android:layout_width="match_parent" 
           android:layout_height="match_parent" 
           android:textSize="24sp" 
           android:text="TextView" 
           android:textColor="#000" /> 
         </LinearLayout> 

         <LinearLayout 
          android:weight="0.25" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:layout_weight="1" 
          android:layout_marginLeft="10dp"> 
          <TextView 
           android:layout_width="match_parent" 
           android:layout_height="match_parent" 
           android:textSize="24sp" 
           android:text="TextView" 
           android:textColor="#000" /> 
         </LinearLayout> 
        </LinearLayout> 

        <LinearLayout 
         android:orientation="vertical" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:layout_weight="1"> 

         <LinearLayout 
          android:weight="0.25" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:layout_weight="1" 
          android:layout_marginLeft="10dp"> 
          <TextView 
           android:layout_width="match_parent" 
           android:layout_height="match_parent" 
           android:text="TextView" 
           android:textColor="#000" 
           android:textSize="24sp"/> 
         </LinearLayout> 

         <LinearLayout 
          android:weight="0.25" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:layout_weight="1" 
          android:layout_marginLeft="10dp"> 
          <TextView 
           android:layout_width="match_parent" 
           android:layout_height="match_parent" 
           android:textSize="24sp" 
           android:text="TextView" 
           android:textColor="#000" /> 
         </LinearLayout> 

         <LinearLayout 
          android:weight="0.25" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:layout_weight="1" 
          android:layout_marginLeft="10dp"> 
          <TextView 
           android:layout_width="match_parent" 
           android:layout_height="match_parent" 
           android:textSize="24sp" 
           android:text="TextView" 
           android:textColor="#000" /> 
         </LinearLayout> 
        </LinearLayout> 

       </LinearLayout> 
      </LinearLayout> 

      <LinearLayout 
       android:orientation="horizontal" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

       <LinearLayout 
        android:orientation="horizontal" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:gravity="center_vertical|center_horizontal"> 

        <TextView 
         android:text="TextView" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:id="@+id/textView83" 
         android:layout_marginBottom="20dp" 
         android:layout_marginTop="20dp" 
         android:textSize="18sp"/> 

       </LinearLayout> 

      </LinearLayout> 

      <LinearLayout 
       android:orientation="horizontal" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

       <LinearLayout 
        android:orientation="vertical" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_weight="1" 
        android:gravity="center_vertical|center_horizontal"> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="TextViewb" 
         android:textColor="#000" 
         android:textSize="24sp"/> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="TextViewc" 
         android:textColor="#000" 
         android:textSize="24sp" 
         android:layout_marginTop="20dp"/> 
       </LinearLayout> 

       <LinearLayout 
        android:orientation="vertical" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_weight="1" 
        android:gravity="center_vertical|center_horizontal"> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="TextViewd" 
         android:textColor="#000" 
         android:textSize="24sp"/> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="TextViewe" 
         android:textColor="#000" 
         android:textSize="24sp" 
         android:layout_marginTop="20dp"/> 
       </LinearLayout> 
      </LinearLayout> 
     </LinearLayout> 
    </ScrollView> 
</LinearLayout> 

出力

one

+0

これはかなり良い動作例です。イメージビューサイズを事前に定義する方法はありますか?サイズは現在画像に基づいているように見えます。 – jaymarvels

+0

mmmこれはすべての画像に適応する必要があります...画像の高さ/幅属性でwrap_contentまたはmatch_parentで値を変更するか、上記のLinear_layoutで 'layout_weight'を変更できます – Aspicas

0

RelativeLayoutLinearLayoutsにはTextViewsが含まれます。

ImageViewallignParentLeftとなり、他の2つのレイアウトは1の重みとイメージビューの左側のレイアウトになります。

関連する問題