2016-10-12 2 views
1

Я работаю над кодом xml, но у меня есть 2 проблемы, a. делая кнопку подходящей для правильного отображения b.Удаление пространства между кнопками. Как сделать кнопку в списке ракурс подходит к любому экрану, а также как удалить пространство между buttons.Please изменить мой код при ответе, благодаря enter image description hereКак сделать кнопку в listview подходящей для любого экрана

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/content_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="org.cepfonline.lwponlineforum.activities.MainActivity" 
    tools:showIn="@layout/app_bar_main"> 

<LinearLayout 
    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" 
     android:orientation="vertical"> 

     <Button 
      android:id="@+id/button01" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1"/> 

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

      <Button 
       android:id="@+id/Button02" 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1"/> 

     </LinearLayout> 

     <Button 
      android:id="@+id/button03" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1"/> 

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

      <Button 
       android:id="@+id/button04" 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1" /> 

     </LinearLayout> 

     <Button 
      android:id="@+id/button05" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1"/> 

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

      <Button 
       android:id="@+id/button06" 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1" /> 

     </LinearLayout> 

    </LinearLayout> 

</LinearLayout> 

ответ

0

Я думаю, промежуток или разность между кнопкой андроида по умолчанию исходит из фонового изображения, используемого в кнопке.

Первый вариант ваш может использовать андроид стиль кнопки, как этот

<Button 
     android:id="@+id/button01" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     style="?android:attr/buttonBarButtonStyle" 
     android:background="@color/colorPrimary" 
     android:layout_weight="1"/> 

Второй вариант заключается в использовании цвета фона на каждой кнопке. Таким образом, полный код, как этого

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/content_main" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

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

    <Button 
     android:id="@+id/button01" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:background="@color/colorPrimary" 
     android:layout_weight="1"/> 

    <Button 
     android:id="@+id/Button02" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:background="@color/colorPrimary" 
     android:layout_weight="1"/> 

    <Button 
     android:id="@+id/button03" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:background="@color/colorPrimary" 
     android:layout_weight="1"/> 

    <Button 
     android:id="@+id/button04" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:background="@color/colorPrimary" 
     android:layout_weight="1" /> 

</LinearLayout> 

изображение до и после

enter image description here

+0

ханжества я закрыть пространство без использования цвета фона трюка – Omega

+0

Нет, потому что я думаю, что это происходит от фоновое изображение по умолчанию. Может быть с прозрачными границами изображений – Inducesmile

+0

, которое по умолчанию не используется, и если есть значение по умолчанию, откуда оно взялось, и как я могу его удалить – Omega

Смежные вопросы