国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

android - layout_widthPercent加載dependencies后還是不能使用,是什么原因?

瀏覽:206日期:2024-08-24 08:41:06

問題描述

為什么添加依賴后,還是不能使用layout_widthPercent/layout_heightPercent?依賴:

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:percent:24.2.1’ compile ’com.android.support:appcompat-v7:24.2.1’ testCompile ’junit:junit:4.12’}

使用layout_widthPercent

<?xml version='1.0' encoding='utf-8'?><android.support.percent.PercentFrameLayout xmlns:android='http://schemas.android.com/apk/res/android' xmlns:app='http://schemas.android.com/apk/res-auto' android:layout_width='match_parent' android:layout_height='match_parent'> <Buttonandroid: android:text='Button1'android:layout_gravity='left|top'android:layout_widthPercent='50%'android:layout_heightPercent='50%'/></android.support.percent.PercentFrameLayout>

告警:

No resource identifier found for attribute ’layout_widthPercent’ in package ’android’

android - layout_widthPercent加載dependencies后還是不能使用,是什么原因?

問題解答

回答1:

謝邀. 沒有使用過 android.support.percent.PercentFrameLayout , 但是從 package 名字就大概知道它是support提供的, 非原生環(huán)境中所支持的Layout. 所以xml代碼應(yīng)該如下:

<?xml version='1.0' encoding='utf-8'?><android.support.percent.PercentFrameLayout xmlns:android='http://schemas.android.com/apk/res/android' xmlns:appCompat='http://schemas.android.com/apk/res-auto' android:layout_width='match_parent' android:layout_height='match_parent'> <Buttonandroid: android:text='Button1'android:layout_gravity='left|top'appCompat:layout_widthPercent='50%'appCompat:layout_heightPercent='50%'/></android.support.percent.PercentFrameLayout>

注意 appCompat 的定義和引用.最后說一點(diǎn), 但凡在代碼里或者layout-xml能引用的Layout(or View), 都是可以正常使用的. 如果報(bào)錯(cuò), 那就是用法用錯(cuò)了.

p.s. 如果答錯(cuò), 請(qǐng)直接踩這個(gè)回答吧(因?yàn)槲覜]具體使用過該P(yáng)ercentFrameLayout).

相關(guān)文章:
主站蜘蛛池模板: 革吉县| 饶河县| 丽水市| 海阳市| 天镇县| 洛浦县| 张家界市| 福鼎市| 康保县| 玉龙| 沅江市| 珲春市| 克什克腾旗| 腾冲县| 修武县| 襄汾县| 沙坪坝区| 威海市| 宁南县| 新和县| 喀喇| 关岭| 江山市| 宜黄县| 湘西| 翁源县| 延庆县| 凤庆县| 随州市| 梨树县| 吴堡县| 册亨县| 平阴县| 南充市| 松阳县| 永春县| 巫山县| 淮安市| 吴川市| 罗平县| 察哈|