久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

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

瀏覽:231日期: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提供的, 非原生環境中所支持的Layout. 所以xml代碼應該如下:

<?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 的定義和引用.最后說一點, 但凡在代碼里或者layout-xml能引用的Layout(or View), 都是可以正常使用的. 如果報錯, 那就是用法用錯了.

p.s. 如果答錯, 請直接踩這個回答吧(因為我沒具體使用過該PercentFrameLayout).

相關文章:
主站蜘蛛池模板: 溧阳市| 永登县| 宝兴县| 灵石县| 仁化县| 龙门县| 开封县| 澜沧| 聂拉木县| 离岛区| 嘉义市| 新建县| 行唐县| 托克托县| 政和县| 和林格尔县| 革吉县| 疏附县| 东丽区| 清镇市| 象州县| 文安县| 金湖县| 伊宁市| 青海省| 遂川县| 晋江市| 衢州市| 砀山县| 红安县| 锡林浩特市| 吉安市| 昌江| 东阿县| 图木舒克市| 怀柔区| 罗田县| 韶山市| 夹江县| 秦皇岛市| 宁陵县|