开发者社区 问答 正文

关于android Button 颜色或者背景的问题

screenshot
Button 颜色问题,我做出来是这个
screenshot

不是透明度的问题,我加了不透明也是不一样的效果

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

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:background="#FF0000" >
    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2"
        android:background="#00FF00" >
    </LinearLayout>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:background="#0000FF" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="#BDBDBD"
            android:text="我是按钮" />
    </RelativeLayout>
</LinearLayout>

展开
收起
爵霸 2016-03-10 11:05:50 2343 分享 版权
1 条回答
写回答
取消 提交回答
  • android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_centerInParent="true"
     android:background="#FFBDBDBD"
     android:text="我是按钮" />

    这样就不透明了,改后面的BDBDBD就可以更换其它颜色。

    2019-07-17 18:57:12
    赞同 展开评论