0

我正在开发一个包含一些文本视图和按钮的Android应用程序。在MultiViewine TextView中TextView结束后放置按钮?

我需要把按钮放在文本视图之后。当我的TextView是单线,运行良好。但是,当使用多行文本视图时,我的按钮被放置到第1行的末尾。

如何将按钮放在正确的位置(在文本视图的最后一行之后)?

编辑后:
这是我的xml,我在我的代码中使用它并动态生成它。

<TableLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:paddingTop="10dp" 
android:shrinkColumns="1" 
android:stretchColumns="1" > 

    <TableRow android:id="@+id/tableRow1" > 
<Button 
    android:id="@+id/ayehPlace_btnCounter" 
    style="?android:attr/buttonStyleSmall" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/ayeh_counter" 
    android:text="" /> 
<TextView 
    android:id="@+id/ayehPlace_txtAyeh" 
    android:layout_width="wrap_content" 
    style="@style/ayehPlace_txt" 
    android:layout_height="wrap_content" 
    android:text="" /> 
</TableRow> 
</TableLayout> 
+0

尝试使用android:baselineAligned =“” – KOTIOS

+2

放置您的布局代码或显示它的一些粗略草图。 –

+0

听起来像你正在寻找'android:gravity =“bottom”'你的(大概)水平'LinearLayout'。 –

回答

0

使用的RelativeLayout并添加

android:layout_toRightOf="@+id/textviewid" 

到按钮。

+0

我这样做,但按钮被放置在文本视图水平线的一端,所以这是行不通的 – user2518719

0

,我会更喜欢使用表格布局instead..it使得UI均匀,并自动调整

<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> 
+0

仍然无法正常工作,按钮放置在水平线的一端 – user2518719

+0

张贴您的XML在这里... –

+0

I post它在我的问题,坦克为你的注意 – user2518719

0

使用表布局,而不是....这工作对我来说..

<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> 
+0

这是行不通的。我添加我的XML到问题 – user2518719

+0

修复android:layout_width到一些数值..对于前 android:layout_width =“120dp” android:layout_height =“wrap_content” android:text =“Lorem ipsum dolor sit amet,consectetur” android:maxLines =“5” android:lines =“5” – ryderz8

0

我想,你需要使用TableLayout和android:gravity =“bottom”。尝试一下。

+0

没有工作,但坦克 – user2518719