0

나는 안드로이드와 함께 일하고 있는데, 나는 화면의 맨 아래에 항상 수평으로 세 개의 버튼이 있어야하는 XML 디자인을 만들어야한다. 안드로이드의 페이스 북 응용 프로그램과 마찬가지로, 화면 하단에 3 개의 버튼 (상태, 사진, 체크인)이 있습니다. 마찬가지로 응용 프로그램에는 항상 3 개의 버튼이 있어야합니다.안드로이드의 facebook처럼 화면 하단에 3 개의 버튼을 표시하는 방법은 무엇입니까?

레이아웃의 종류는 어떻게됩니까?

나는 아래의 XML 디자인 시도했지만 어떻게 든 작동하지 않습니다 그들은 모두 수직오고있다 -

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

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:text="@string/cow" 
     android:layout_weight="0" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1" 
     android:gravity="center|bottom" 
     android:orientation="vertical" > 

     <Button 
      android:id="@+id/button1" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="145dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal|center" 
      android:text="ButtonA" /> 

     <Button 
      android:id="@+id/button2" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="145dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal|center" 
      android:text="ButtonB" /> 

     <Button 
      android:id="@+id/button3" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="145dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal|center" 
      android:text="ButtonC" /> 
    </LinearLayout> 

</LinearLayout> 

난 그냥 단지 페이스 북의 쇼처럼 수평으로 화면 아래쪽에 세 개의 버튼을 표시해야 항상 나란히 (서로 닿아). 가능한가요? 버튼 이름이 될 수

- 레이아웃 아래 ButtonA, ButtonB and ButtonC

+0

레이아웃에서 6 개의 버튼이 선언 된 이유는 무엇입니까? – joao2fast4u

+0

RelativeLayout의 'buttons.layout_below' 아래쪽에있는 LinearLayout의 버튼이있는 ScrollView가 필요할 것입니다. – ChiefTwoPencils

+0

LinearLayout에'android : orientation = "vertical"'이 있기 때문에 수직입니다. 그것을 수평으로 변경하십시오. – Karakuri

답변

1

사용, 정말,

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

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0" 
     android:gravity="center" 
     android:text="cow" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 
</LinearLayout> 

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

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

    <Button 
     android:id="@+id/button2" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="ButtonB" /> 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="ButtonC" /> 
</LinearLayout> 

0

의 도움 당신은 당신이 결국이를 조정해야할지 모르겠 생각 나는 매우 일반적인 것으로 남겨 두었습니다 :

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

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" /> 

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

     <View 
      android:layout_width="0dp" 
      android:layout_height="1dp" 
      android:layout_weight="2" /> 

     <Button 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 

     <Button 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 

     <Button 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 

     <View 
      android:layout_width="0dp" 
      android:layout_height="1dp" 
      android:layout_weight="2" /> 

    </LinearLayout>   

</LinearLayout> 
0

어쩌면 당신은 이 같은 머리말 - 꼬리말-내용 구조 :

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

<!-- Header aligned to top --> 
<RelativeLayout 
    android:id="@+id/header" 
    android:layout_alignParentTop="true" 
    ...> 
</RelativeLayout> 

<!-- Footer aligned to bottom --> 
<RelativeLayout 
    android:id="@+id/footer" 
    android:layout_alignParentBottom="true" 
    ...> 
    <!-- put your layout and buttons here --> 
</RelativeLayout> 

<!-- Content below header and above footer --> 
<RelativeLayout 
    android:id="@+id/content" 
    android:layout_above="@id/footer" 
    android:layout_below="@id/header" 
    ...> 
</RelativeLayout> 

당신은 당신의 의지에 조각을 제거 할 수 있습니다.

관련 문제