Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何设置视图组的样式/主题_Android - Fatal编程技术网

Android 如何设置视图组的样式/主题

Android 如何设置视图组的样式/主题,android,Android,有人能告诉我如何设置ViewGroup类的样式吗?我试图在互联网上找到解决方案,但没有成功 谢谢。在res文件夹中的style.xml文件中定义样式,如下所示: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"

有人能告诉我如何设置ViewGroup类的样式吗?我试图在互联网上找到解决方案,但没有成功


谢谢。

在res文件夹中的style.xml文件中定义样式,如下所示:

<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="wrap_content"
    android:gravity="center_vertical"
    android:orientation="horizontal"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    style="@style/AppTheme"  // <--------- reference your style here
    >
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

<style name="Style_Button_SquareGrayLight">
        <item name="android:textColor">@color/white</item>
        <item name="android:background">@drawable/button_basic_gray_rounded_corners</item>
        <item name="android:textSize">@dimen/button</item>
        <item name="android:typeface">sans</item>
        <item name="android:textStyle">bold</item>
        <item name="android:layout_height">35dip</item>
        <item name="android:paddingLeft">10dip</item>
        <item name="android:paddingRight">10dip</item>
        <item name="android:singleLine">true</item>
    </style>
</resources>
<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:layout_marginLeft="@dimen/page_left_padding"
        android:layout_marginRight="0dip"
        android:layout_marginTop="@dimen/page_top_padding"
style="@style/Style_Button_SquareGrayLight"/>

@颜色/白色
@可拉伸/按钮\基本\灰色\圆角
@尺寸/按钮
桑
大胆的
35度
10度
10度
真的
如上所述,我的样式名为“style_Button_SquareGrayLight”,现在您可以使用style=“@style/AppThemeName”属性将此样式设置为任何视图或视图组,如下所示:

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

<style name="Style_Button_SquareGrayLight">
        <item name="android:textColor">@color/white</item>
        <item name="android:background">@drawable/button_basic_gray_rounded_corners</item>
        <item name="android:textSize">@dimen/button</item>
        <item name="android:typeface">sans</item>
        <item name="android:textStyle">bold</item>
        <item name="android:layout_height">35dip</item>
        <item name="android:paddingLeft">10dip</item>
        <item name="android:paddingRight">10dip</item>
        <item name="android:singleLine">true</item>
    </style>
</resources>
<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:layout_marginLeft="@dimen/page_left_padding"
        android:layout_marginRight="0dip"
        android:layout_marginTop="@dimen/page_top_padding"
style="@style/Style_Button_SquareGrayLight"/>


同样,您也可以设置按钮、文本视图等视图。

在res文件夹的style.xml文件中定义样式,如下所示:

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

<style name="Style_Button_SquareGrayLight">
        <item name="android:textColor">@color/white</item>
        <item name="android:background">@drawable/button_basic_gray_rounded_corners</item>
        <item name="android:textSize">@dimen/button</item>
        <item name="android:typeface">sans</item>
        <item name="android:textStyle">bold</item>
        <item name="android:layout_height">35dip</item>
        <item name="android:paddingLeft">10dip</item>
        <item name="android:paddingRight">10dip</item>
        <item name="android:singleLine">true</item>
    </style>
</resources>
<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:layout_marginLeft="@dimen/page_left_padding"
        android:layout_marginRight="0dip"
        android:layout_marginTop="@dimen/page_top_padding"
style="@style/Style_Button_SquareGrayLight"/>

@颜色/白色
@可拉伸/按钮\基本\灰色\圆角
@尺寸/按钮
桑
大胆的
35度
10度
10度
真的
如上所述,我的样式名为“style_Button_SquareGrayLight”,现在您可以使用style=“@style/AppThemeName”属性将此样式设置为任何视图或视图组,如下所示:

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

<style name="Style_Button_SquareGrayLight">
        <item name="android:textColor">@color/white</item>
        <item name="android:background">@drawable/button_basic_gray_rounded_corners</item>
        <item name="android:textSize">@dimen/button</item>
        <item name="android:typeface">sans</item>
        <item name="android:textStyle">bold</item>
        <item name="android:layout_height">35dip</item>
        <item name="android:paddingLeft">10dip</item>
        <item name="android:paddingRight">10dip</item>
        <item name="android:singleLine">true</item>
    </style>
</resources>
<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:layout_marginLeft="@dimen/page_left_padding"
        android:layout_marginRight="0dip"
        android:layout_marginTop="@dimen/page_top_padding"
style="@style/Style_Button_SquareGrayLight"/>


同样,您也可以设置按钮、文本视图等视图。

您能告诉我们您尝试了什么吗?您能告诉我们您尝试了什么吗?谢谢您的回答,但我指的是查看组类,抱歉让您失望。谢谢您的回答,但我指的是查看组类,对不起,让人失望。谢谢你的回答,但我是指“查看组”课。对不起,让人失望。谢谢你的回答,但我是指“查看组”课。对不起,让人失望。