我创建了一个将 TextView 显示为垂直的活动。文本视图后面有额外的空间。如何删除多余的空间。以下布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Theme.MyApplication.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/Theme.MyApplication.PopupOverlay"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp">
<TextView
android:id="@+id/app_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AppMod"
android:textStyle="bold"
android:rotation="-90"
android:gravity="fill_vertical"
android:includeFontPadding="false"
android:background="@drawable/text_border"
android:onClick="onAppModeChange"
android:clickable="true"
/>
<LinearLayout
android:id="@+id/tbViewsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:orientation="vertical">
<TextView
android:id="@+id/tb_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Line 1"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
android:focusable="true"
android:textColor="@android:color/white"
android:textStyle="bold"
/>
<TextView
android:id="@+id/tb_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-5dp"
android:text="Line 2"
android:singleLine="true"
/>
<TextView
android:id="@+id/tb_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-5dp"
android:text="Line 3"
android:singleLine="true"
/>
</LinearLayout>
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
</LinearLayout>
这是因为当你旋转 witdh 时仍然相同,你有一些选择
Rotate Layout
TextView
的宽度并添加所需的宽度以适合您的 textSize
VerticalTextView
或 VerticalTextView
android:text="A\np\np\nM\no\nd\ne\nl"