0
目前我正在嘗試創建一個主要是horizontalscrollview和主視圖的小應用程序。 horizontalscrollview包含一個線性佈局,在我的BoxItem.axml文件中定義了一堆BoxItem。一個BoxItem也顯示在主視圖上。在axml或c中縮放視圖#
問題是我需要縮小項目以適合滾動視圖。我希望項目自動調整大小(及其所有子視圖)以適合父視圖(高度)。
如果可能的話,我還想實現一個函數set代碼的大小(但這不是我主要關心的)。
BoxItem.axml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/Box"
android:gravity="center_vertical">
<TextView
android:text="Shelf"
android:id="@+id/Shelf"
android:textColor="#009900"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="30sp" />
<TextView
android:text="ProductName"
android:id="@+id/Name"
android:textColor="#009900"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="30sp" />
<TextView
android:text="Barcode"
android:id="@+id/Barcode"
android:textColor="#009900"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="30sp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout3"
android:gravity="center">
<TextView
android:text="10"
android:id="@+id/StockCurrent"
android:textColor="#009900"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="30sp" />
<TextView
android:text="/"
android:id="@+id/textView4"
android:textColor="#009900"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="30sp" />
<TextView
android:text="10"
android:id="@+id/StockMax"
android:textColor="#009900"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="30sp" />
</LinearLayout>
</LinearLayout>
@ b.holz,你解決了你的問題嗎? –