简体   繁体   English

使用6个按钮从此布局中删除“填充”空间

[英]Remove “padding” space from this layout with 6 buttons

Im working on a android app wich one of the activity will have the following layout (cant embed images, new account): 我正在从事其中一项活动的android应用程序上的工作将具有以下布局(无法​​嵌入图片,新帐户):

布局

XML Code of this activity: 此活动的XML代码:

<?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"
tools:context="com.example.bugdroid.sintomas1.Motivo_sintoma">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_below="@+id/linearLayout3"
    android:layout_alignParentStart="true">

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

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

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

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:id="@+id/linearLayout2">

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

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

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

</LinearLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_below="@+id/linearLayout2"
    android:layout_alignParentStart="true"
    android:id="@+id/linearLayout3">

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

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

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

</LinearLayout>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/button9"
    android:layout_marginRight="0dip"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_toEndOf="@+id/button10" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/button10"
    android:layout_alignTop="@+id/button9"
    android:layout_alignParentStart="true" />

I want the layout to look this mookup: 我希望布局看起来像这个模型:

所需结果

2 : I also want to remove it on the buttons at the bottom and join them into one as see on the image. 2 :我也想删除底部按钮上的按钮,然后将其合并为一个,如图所示。

The issue is in Button background. 问题出在Button背景中。 Default background is the following (file btn_default.xml in platform resources): 默认背景如下(平台资源中的文件btn_default.xml):

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_window_focused="false" android:state_enabled="true"
        android:drawable="@drawable/btn_default_normal" />
    <item android:state_window_focused="false" android:state_enabled="false"
        android:drawable="@drawable/btn_default_normal_disable" />
    <item android:state_pressed="true" 
        android:drawable="@drawable/btn_default_pressed" />
    <item android:state_focused="true" android:state_enabled="true"
        android:drawable="@drawable/btn_default_selected" />
    <item android:state_enabled="true"
        android:drawable="@drawable/btn_default_normal" />
    <item android:state_focused="true"
        android:drawable="@drawable/btn_default_normal_disable_focused" />
    <item
         android:drawable="@drawable/btn_default_normal_disable" />
</selector>

All items are 9patches. 所有项目均为9个补丁。 So, I would suggest to use Your own backgrounds (or modify platform backgrounds and remove paddings using 9patch tool 因此,我建议您使用自己的背景(或使用9patch工具修改平台背景并删除填充)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM