我是新來的android編程。我正在實現一個簡單的計算器,我正面臨水平滾動視圖的問題。我正在使用水平滾動視圖中的編輯文本。它第一次工作完全正常,但一旦我清除了屏幕,它仍然保持滾動限制,這意味着即使屏幕上的數字很少,我也能夠滾動更多。我想實現的是限制它的滾動。以下是屏幕截圖和XML代碼。水平滾動查看,滾動發佈Android
[第二時間] [2]
It is still scroll-able even though there are few digits
<HorizontalScrollView
android:id="@+id/hsvMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:scrollbars="none"
>
<EditText
android:id="@+id/mainEditText"
android:paddingTop="10dp"
android:paddingRight="2dp"
android:background="#ffff"
android:ellipsize="end"
android:focusable="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="55sp"
android:textStyle="bold"
/>
</HorizontalScrollView>
嘗試設置編輯文本layout_width @ height to wrap_content –