以下是我从github实现ShapeOfView库后的简单xml布局文件。
<LinearLayout 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"
android:orientation="vertical"
android:weightSum="10">
<com.github.florent37.shapeofview.shapes.DiagonalView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:elevation="4dp"
app:shape_diagonal_angle="6"
app:shape_diagonal_direction="right"
app:shape_diagonal_position="bottom">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/homepage" />
</com.github.florent37.shapeofview.shapes.DiagonalView>
但是当我调试它时会出现此错误
Android resource linking failed
/home/.../fragment_home.xml:9: error: attribute shape_diagonal_direction not found.
error: failed linking file resources.
那是为什么?
答案 0 :(得分:1)
我刚刚删除了该属性(app:shape_diagonal_direction =“ right”),它对我有用! 使用此代码。
<LinearLayout 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"
android:orientation="vertical"
android:weightSum="10">
<com.github.florent37.shapeofview.shapes.DiagonalView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:elevation="4dp"
app:shape_diagonal_angle="6"
app:shape_diagonal_position="bottom">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/homepage" />
</com.github.florent37.shapeofview.shapes.DiagonalView>
</LinearLayout>
答案 1 :(得分:0)
删除那一行,问题是因为库版本,它只是删除那个属性。
一定是这样的:
<com.github.florent37.shapeofview.shapes.DiagonalView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:elevation="4dp"
app:shape_diagonal_angle="6"
app:shape_diagonal_position="bottom">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/homepage" />
</com.github.florent37.shapeofview.shapes.DiagonalView>