2013-07-03 6 views
12

I는 다음과 같은 한 레이아웃 : 난 main_imgBreachAlert 로이드 설정안드로이드 상대 레이아웃 정렬 상위 오른쪽

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/test_ll" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/background" 
android:orientation="vertical" > 

<RelativeLayout 
    android:id="@+id/main_layPanelCircle" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_vertical|center_horizontal" 
    android:layout_marginLeft="10dp" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="15dp" 
    android:background="@drawable/main_panel_a" 
    android:orientation="vertical" 
    android:padding="10dp" > 

    <ImageView 
     android:id="@+id/main_imgBreachAlert" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="5dp" /> 

    <Button 
     android:id="@+id/main_btnMap" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:background="@null" 
     android:drawableTop="@drawable/icon_find" 
     android:text="@string/main_locate" 
     android:textColor="@android:color/white" 
     android:textSize="10sp" /> 

    <LinearLayout 
     android:id="@+id/main_llPanelCycleMiddle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/main_btnMap" 
     android:layout_centerInParent="true" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/main_btnLeft" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@null" 
      android:drawableTop="@drawable/icon_call" 
      android:text="@string/main_call" 
      android:textColor="@android:color/white" 
      android:textSize="10sp" 
      android:visibility="visible" /> 

     <Button 
      android:id="@+id/main_btnEmergency" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@null" 
      android:drawableTop="@drawable/icon_emergency" 
      android:scaleType="center" 
      android:text="@string/main_emergency" 
      android:textColor="@android:color/white" 
      android:textSize="9sp" 
      android:textStyle="bold" /> 

     <Button 
      android:id="@+id/main_btnRight" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@null" 
      android:drawableTop="@drawable/icon_store" 
      android:text="@string/main_store" 
      android:textColor="@android:color/white" 
      android:textSize="10sp" /> 
    </LinearLayout> 

    <Button 
     android:id="@+id/main_btnMore" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/main_llPanelCycleMiddle" 
     android:layout_centerHorizontal="true" 
     android:background="@null" 
     android:drawableTop="@drawable/icon_more" 
     android:text="@string/main_more" 
     android:textColor="@android:color/white" 
     android:textSize="10sp" /> 
</RelativeLayout> 

</LinearLayout> 

: layout_alignParentLeft가 = "true"로 eveerything은 (왼쪽 화상) OK이다하지만 오른쪽 내 상대 레이아웃 뻗어로 설정할 때 (왼쪽 이미지) :

http://i.imgur.com/uDJqF0k.jpg?1

당신은 내가이 문제를 해결할 수있는 방법을 알려 주시기 바랍니다 수 없습니다.

Thnx는

+0

동시에 부모와 동시에 정렬 하시겠습니까? 그렇다면 wrap_content를 오버라이드하여 부모를 채우도록 강요합니다 (두 가지 악의 영향이 적고 다른 옵션은 레이아웃의 다른 요소를 같은 크기로 축소하는 것입니다). –

+0

질문에 대한 답변을 찾았습니까? Iam이 똑같은 문제를 겪고있다. – Snake

답변

26

android:layout_centerInParent="true"을 시도하고 당신이 당신의 레이아웃을 중심으로 이미지를 원하는 경우 alignParentLeft 속성을 제거합니다.

오른쪽으로 만 정렬하려면 을 사용하십시오.

<ImageView 
    android:id="@+id/main_imgBreachAlert" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="5dp" /> 
+2

오른쪽에 이미지를 설정하고 싶지 않다. – Damir

+1

그런 다음 android : alignParentRight = "true"를 사용하고 alignParentLeft 특성을 제거하십시오. – Flynn81

+2

alignParentRight를 설정하면이 컨트롤이있는 부모가 늘어납니다. 내 접근 방식이 잘못되었습니다. 나는 실제로 레이아웃 배경을 설정하고 그 배경 주위에 레이아웃을 감싸고 그 레이아웃 안에 다른 컨트롤을 넣기를 원하지만 배경 이미지 주위에 을 감싸 야한다. 이것이 의미가있는 경우. – Damir

관련 문제