android怎么样使按钮之间的部分空间,使得上述每个人白线 [英] android how to make some space between buttons and make white line above each of them

查看:157
本文介绍了android怎么样使按钮之间的部分空间,使得上述每个人白线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有能力用xml背景两个按钮,我想保持它们之间的一些空间,因为那是过去的正是对方,我也想将白线之上他们,我会给你我怎么尝试,但它不我将不起作用。

I have two buttons with xml background , i want to keep some space between them, because that are past exactly on each other , also i want to put white line above them , i will give you how i tried but it doesn't work with me

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="25dip"

    android:orientation="horizontal"

    android:weightSum="2" >

    <Button
        android:background="@drawable/button_selector"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:textColor="#FFFFFF"
        android:gravity="center"
        android:textStyle="bold"
        android:text="@string/b_save" />

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:textColor="#FFFFFF"
        android:gravity="center"
        android:background="@drawable/button_selector"
        android:text="@string/b_cancel" />
</LinearLayout>

XML背景

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <padding android:top="10dip"
        android:bottom="10dip"/>



    <!-- Gradient Bg for listrow -->
    <gradient
        android:useLevel="false"
        android:angle="270"
        android:centerColor="#000000"
        android:endColor="#FFFFFF"
        android:startColor="#808080" />
</shape>

推荐答案

检查了这一点。

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <padding android:top="10dip"
        android:bottom="10dip"/>



    <!-- Gradient Bg for listrow -->
    <gradient
        android:useLevel="false"
        android:angle="270"
        android:centerColor="#808080"
        android:endColor="#000000"
        android:startColor="#FFFFFF" />
</shape>

button_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <padding android:top="10dip"
        android:bottom="10dip"/>



    <!-- Gradient Bg for listrow -->
    <gradient
        android:useLevel="false"
        android:angle="270"
        android:centerColor="#000000"
        android:endColor="#808080"
        android:startColor="#FFFFFF" />
</shape>

您的XML

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="25dip"
    android:orientation="horizontal"
    android:background="@drawable/bg_selector"
    android:weightSum="2" >

    <Button
        android:background="@drawable/bg_selector"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:textColor="#FFFFFF"
        android:gravity="center"
        android:textStyle="bold"
        android:layout_marginRight="4dip"
        android:layout_marginLeft="10dip"
        android:text="@string/b_save" />

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:textColor="#FFFFFF"
        android:gravity="center"
        android:layout_marginLeft="4dip"
        android:layout_marginRight="10dip"
        android:background="@drawable/bg_selector"
        android:text="@string/b_cancel" 
        android:textStyle="bold"/>
</LinearLayout>

这篇关于android怎么样使按钮之间的部分空间,使得上述每个人白线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆