[英]android rotated TextView inherits the parent's width
好吧,經過幾個小時的網絡搜索但沒有結果,或者有人寫課程來做到這一點,並且在發布問題后僅 30 分鍾,我就設法實現了我想要的。
我將 TextView 放在 FrameLayout 中,現在它不繼承其父寬度。 還給了它一個方形比例和一個layout_gravity,代碼如下:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="20dp"
android:layout_height="wrap_content">
<TextView
android:id="@+id/text"
android:layout_width="120dp"
android:layout_height="120dp"
android:rotation="-90"
android:text="january"
android:textSize="14sp"
android:gravity="center|right"
android:layout_gravity="top|center"
android:paddingRight="8dp"
android:background="@color/itemMainBgColor"/>
</FrameLayout>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.