Android 如何在文本视图右侧添加按钮

Android 如何在文本视图右侧添加按钮,android,xml,android-relativelayout,android-framelayout,Android,Xml,Android Relativelayout,Android Framelayout,我想在textview右侧添加一个按钮,如果textview增长,按钮仍将存在。我使用了FrameLayout或RelativeLayout,但它们不起作用,请帮助我。 类似于此图像的布局尝试使用线性布局,将方向设置为水平 <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="hor

我想在textview右侧添加一个按钮,如果textview增长,按钮仍将存在。我使用了FrameLayout或RelativeLayout,但它们不起作用,请帮助我。
类似于此图像的布局

尝试使用
线性布局
,将
方向设置为
水平

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/textView_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight=".5"
            android:text="your text"
             />

        <Button
            android:id="@+id/button_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight=".5"
            android:text="button" />

       </LinearLayout>


这不可能直接实现,对于Android开发也不是一个好的实践。如果这是您的要求,那么您可以在运行时计算最后一行中的行数和字符数,并通过使用帧或相对布局来确定按钮的位置

请发布你的布局。我以前试过,但不起作用。我想要一个像这样的布局