2013-09-03 2 views
0

아래 링크에 표시된 화면의 레이아웃을 달성하려면 코드를 공유하십시오. 텍스트는 두 이미지의 가운데에 있어야하며이 모든 구성 요소는 동적 일 수 있습니다.두 개의 ImageView와 중간 아래에 TextView 배치 - Android

(https://docs.google.com/file/d/0B9n2IhVep_QeNDFKaWFHVERQOVk/edit?usp=sharing)

https://www.dropbox.com/s/2j4bpwdmv0wgesg/Untitled%20Diagram.png

+2

공유 대중의 허가 – Saeed

+0

와 링크를 시도하십시오이 하나 https://www.dropbox.com/s/2j4bpwdmv0wgesg/Untitled%20Diagram.png – Jaffy

답변

0

희망이

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/pager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    > 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     /> 

    <ImageView 
     android:id="@+id/imageView2" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     /> 
</LinearLayout> 

<TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:gravity="center_horizontal" 
     android:text="TextView" /> 

</LinearLayout> 
0

당신은 모양의 사용자 정의 드로어 블을 추가해야이

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/yourBackgroundDrawableBorder" 
    android:src="@drawable/ic_launcher" /> 

<ImageView 
    android:id="@+id/imageView2" 
    android:background="@drawable/yourBackgroundDrawableBorder" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toRightOf="@id/imageView1" 
    android:padding="xxdp" 
    android:src="@drawable/ic_launcher" /> 

<TextView 
    android:id="@+id/global_menu_edit" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/imageView1" 
    android:layout_centerHorizontal="true" 
    android:text="Textview" /> 

</RelativeLayout> 

이다 할 수있는 쉬운 방법을 작동 당신은 당신의 의견을 원하고 .. 그리고 분명히이 그것을하는 아주 일반적인 방법입니다. 일부 속성을 편집하거나 필요에 맞게 일부 속성을 추가해야합니다. 다른 방법은 LinearLayout과 android:layout_weight="1" 속성을 사용하여 이미지 뷰의 크기를 비슷하게 만드는 것입니다.

+0

내가 3 쌍을 만들고 싶어 코딩하는 방법 이미지와 유사하게 텍스트를 쌍 아래 및 중앙에 배치하십시오. – Jaffy

+0

비슷하게 작동 할 것입니다 .3 개의 imageviews에 모두 같은 크기의 이미지를 제공 할 수있는 weight 속성 ... 그리고 그 중 3 개를 선형 레이아웃 안에 넣으십시오. 속성을 시험 할 필요가있다. – Android2390

0
<?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:gravity="center" 
android:orientation="vertical" 
android:padding="5dp" > 

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

    <ImageView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:adjustViewBounds="true" 
     android:scaleType="fitXY" 
     android:src="@drawable/ic_launcher" /> 

    <ImageView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:adjustViewBounds="true" 
     android:layout_marginLeft="10dp" 
     android:scaleType="fitXY" 
     android:src="@drawable/ic_launcher" /> 
</LinearLayout> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:lines="3" 
    android:layout_marginTop="10dp" 
    android:text="Text" /> 
</LinearLayout> 
관련 문제