小编Man*_*mar的帖子

TranslationZ在Android中实际做了什么?

嗨,我正在开发Android应用程序,我正在尝试实现新的材料设计功能.我试图应用提升属性和TranslationZ属性,但它不起作用.

<Button
    android:id="@+id/button1"
    style="@style/ButtonStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:text="Name" />  
Run Code Online (Sandbox Code Playgroud)

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <solid android:color="#0073ff" />
    <corners android:radius="16dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)

<style name="ButtonStyle">
        <item name="android:elevation">8dp</item>
        <item name="android:translationZ">8dp</item>
        <item name="android:background">@drawable/file</item>
</style>
Run Code Online (Sandbox Code Playgroud)

android material-design android-5.0-lollipop

10
推荐指数
1
解决办法
1万
查看次数

在xml中未检测到TextView autoSizeTextType

我正在寻找自动更改TextView大小.我也找到了解决方案.以下是自动调整文本视图的官方文档.但我还是无法解决它.当我将autoSizeTextType粘贴到xml文件中时显示错误.

这是我的xml代码和gradle代码片段

myactivity.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical">

<include layout="@layout/toolbar" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:autoSizeTextType="uniform"/>


</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

Gradle片段

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:support-v4:25.2.0'//Added support library
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support:design:25.2.0'
    testCompile 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)

xml android textview android-support-library

6
推荐指数
2
解决办法
5867
查看次数