私はそれの中にTextViewのLinearLayoutを持っているhorizontalscrollviewを持っています。
私は動的に設定していますStringは長いですTextView(計算機のような)のたびに、しかし、TextViewが広くなると、私はそれの最初にスクロールすることはできません(私の便利な左側に)、しかし、ちょうどいくつかの空ですどのようにそれが来たのか分かりません。
一般に、レイアウト内のTextViewの一部を表示するには、片側(左)にスクロールしないでください。
これはスクロールビューのxmlです:
<HorizontalScrollView
android:id="@+id/Hscrollbar"
android:layout_width="match_parent"
android:layout_height="35dp"
android:foregroundGravity="right"
android:fillViewport="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_gravity="center">
<TextView
android:id="@+id/logs"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:scrollHorizontally="true"
android:text="v"
android:textColor="#ffffff"
android:textSize="30dp" />
</LinearLayout>
</HorizontalScrollView>
私の活動でも、これをHorizontalScrollViewに変更しました:
final HorizontalScrollView Hscrollbar = (HorizontalScrollView)findViewById(R.id.Hscrollbar);
Hscrollbar.post(new Runnable() {
@Override
public void run() {
Hscrollbar.fullScroll(View.FOCUS_RIGHT);
}
});
左側にスクロールさせるにはどうすればいいですか(TextView全体を見たいのですが)?
回答:
回答№1は0android:foregroundGravity = "right"をHorizontalScrollViewから削除します。
LinearLayoutの幅をwrap_contentに、TextViewで同じにします。
TextViewを設定するandroid:layout_gravity = "right"
それはうまくいくかもしれない。