我正在尝试如下所述进行布局。我不明白如何准确地实现布局。
布局和上面的六边形将有一些我需要从代码中动态更改的文本。
我尝试过这里提到的类似方法
但六边形仍在剪裁。我正在使用以下代码。
<RelativeLayout
android:id="@+id/Llfirstamount"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:background="@color/layoutcolor1"
android:clickable="true"
android:clipChildren="false" >
<TextView
android:id="@+id/my_first_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:android:layout_alignParentBottom="true"
android:android:layout_alignParentLeft="true"
android:padding="15dp"
android:text="Amount"
android:textColor="@android:color/white" />
<TextView
android:id="@+id/my_second_text"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="-20dp"
android:background="@drawable/hexagon"
android:clipToPadding="false"
android:contentDescription="@string/contentdesc_peso_logo"
android:gravity="center"
android:text="x5" />
</RelativeLayout>
我不知道这是唯一的方法还是正确的方法,或者有更好的方法来实现这一点。我很困惑。请帮忙!!!谢谢你..
编辑:
好的,感谢您使用两个具有自定义背景的文本视图的回答是一个好主意。现在我正在使用编辑后的代码,但六边形正在裁剪,如下所示..
我错过了什么我还添加了
android:clipToPadding="false"
和
android:clipChildren="false"
在我的代码中。