android - TextView pushes buttons off screen with HorizontalScrollView -


i aiming layout similar native calculator app. want text trail off left of screen without moving buttons on right. text moves left until filling screen @ point buttons pushed off right edge.

<linearlayout     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_gravity="top"     android:layout_weight="1"     android:gravity="right"     android:orientation="horizontal" >      <horizontalscrollview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:scrollbars="none" >          <textview             android:id="@+id/display_view"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:singleline="true"             android:textcolor="@android:color/white"             android:textisselectable="true"             android:textsize="30sp" />     </horizontalscrollview>      <linearlayout         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:orientation="vertical" >          <button             android:id="@+id/delete_button"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:onclick="ondelete"             android:text="@string/delete_button" />          <button             android:id="@+id/equate_button"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:onclick="onequate"             android:text="@string/equate_button" />     </linearlayout> </linearlayout> 

you don't need put textview horizontalscrollview, automatically become scrollable when text exceeds bounds. see docs: http://developer.android.com/reference/android/widget/textview.html#attr_android:scrollhorizontally

just add android:scrollhorizontally="true" textview in layout.

you may need change text view's layout_weight 0 or set layout_width fixed (like 100dp).

to text go right-to-left, set gravity on textview android:gravity="right|center_vertical"

i humbly refer source of calculator app trying emulate: https://github.com/android/platform_packages_apps_calculator/tree/master/src


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -