Place Button just after end of TextView in multilline TextView?

可紊 提交于 2019-12-06 04:29:41

Use Table Layout instead .... It worked for me ..

<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="10dp"
    android:shrinkColumns="1"
    android:stretchColumns="1" >

    <TableRow
        android:descendantFocusability="beforeDescendants"
        android:focusable="true"
        android:focusableInTouchMode="true" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Your Text" />

        <Button
            android:id="@+id/button_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""/>
    </TableRow>
    </TableLayout>  
blganesh101

Use RelativeLayout and add

android:layout_toRightOf="@+id/textviewid" 

to Button.

I'll prefer to use table layout instead..it makes the UI uniform and adjusts automatically

<TableLayout
       xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent"
       android:layout_height="match_parent"
       android:padding="5dp"
       android:shrinkColumns="1"
       android:stretchColumns="1" >

       <TableRow android:id="@+id/tableRow1" >

           <TextView
               android:id="@+id/textView1"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="Main Status             "
               android:textAppearance="?android:attr/textAppearanceMedium" />

           <Button
               android:id="@+id/retentionMainStatus"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="CLICK ME" />
</TableRow>
</TableLayout>

I think, you need to use TableLayout together with android:gravity="bottom". Try it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!