我正在尝试实现百分比相对布局,并遵循本教程:
https://blog.stylingandroid.com/percent-part-1/
我的代码中似乎没有任何错误,但仍然没有预览,上面写着:
"呈现问题渲染过程中出现异常:android/support/%R$styleable"
知道怎么了吗?
我在"build.gradle(模块:应用程序)"中的依赖项是:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.0.0-alpha1'
compile 'com.android.support:percent:23.0.0'
}
顶部的两个从一开始就在那里。
我的XML文件:
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_paddingRightPercent="2%"
app:layout_paddingLeftPercent="2%"
app:layout_paddingBottomPercent="2%"
tools:context="companyname.appname.SeLister">
<TextView android:text="Reklame"
app:layout_heightPercent="10%"
app:layout_widthPercent="50%"
android:id="@+id/listereklame"
android:textColor="#000000"
android:background="@drawable/tekstboks1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
/>
</android.support.percent.PercentRelativeLayout>
我想我解决了这个问题。从初始化标记中删除padding属性。希望这能对其他有同样问题的人有所帮助,干杯!