2013-07-04 3 views
0

코드를 실행할 때 옆에 버튼이있는 이미지가 나타납니다. 버튼이없는 화면의 왼쪽에 이미지가 표시됩니다. 이미지가 첫 번째 또는 두 번째로 나열됩니다.버튼이 선형 레이아웃을 사용하는 앱에 표시되지 않음

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/LinearLayout01" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:gravity="bottom" > 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_weight="5" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:contentDescription="@string/none" 
     android:src="@drawable/oxwichpointtest" /> 

    <Button 
     android:id="@+id/button1" 
     android:layout_weight="1" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:onClick="openGuide" 
     android:text="@string/button_text" /> 

</LinearLayout> 

UPDATE : 모든 제안을 주셔서 감사합니다. 나는 그들 모두를 밖으로 시도했지만 내 애플 리케이션 레이아웃에 변화가 없어서 문제가 .java 파일에 이미지를 설정 한 방법에 있다고 생각된다. 이것을 바꾸려고 노력할 것이기를 바랍니다. 문제가 계속된다면 나중에 코드를 추가 할 수도 있습니다. 다시 한 번 감사드립니다. 적어도 레이아웃에 중대한 문제는 없음을 알았습니다.

+0

사용'안드로이드 : = "1"'이미지 뷰 및 확인에 layout_weight. – Raghunandan

+0

이 작품은 나를 위해 벌금! – Nargis

+0

시작 : android : layout_width = "match_parent", android : orientation = "horizontal"및 xmlns : tools이 도구를 사용하고 있습니까? 또한 안드로이드를 배치하는 것이 좋을 것입니다 : weightSum = "6" –

답변

-1

Android에서는 Android : layout_weight = "1"을 사용합니다. !

및 이미지 뷰 버튼에 원하는대로 무게의 일부를 할당 예보다

다음의 LinearLayout에 대한 방향 속성 :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/LinearLayout01" 
android:layout_width="fill_parent" 
android:layout_height="match_parent" 
android:gravity="bottom" android:layout_weight="1"> 

<ImageView 
    android:id="@+id/imageView1" 

    android:layout_width="10dp" 
    android:layout_height="wrap_content" 
    android:contentDescription="@string/none" 
    android:src="@drawable/oxwichpointtest" android:layout_weight="0.5"/> 

<Button 
    android:id="@+id/button1" 

    android:layout_width="10dp" 
    android:layout_height="wrap_content" 
    android:onClick="openGuide" 
    android:text="@string/button_text" android:layout_weight="0.5"/></LinearLayout> 
+0

요구 사항을 충족하는 경우 답변으로 만드십시오. –

+0

너비가 –

0

안드로이드 누락?

+1

인 적절한 dp 값을 사용하십시오. 응답이 아니라 주석이어야합니다. – Houcine

0

레이아웃 선언에 속성이 누락되었을 수 있습니다.

안드로이드 : 오리엔테이션 = "horinzontal"

코드 :

<?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/LinearLayout01" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="bottom" 
    android:orientation="horinzontal" > 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_weight="5" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:contentDescription="@string/none" 
     android:src="@drawable/oxwichpointtest" /> 

    <Button 
     android:id="@+id/button1" 
     android:layout_weight="1" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:onClick="openGuide" 
     android:text="@string/button_text" /> 

</LinearLayout> 
+1

기본 방향 == 가로 – Prachi

관련 문제