Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在文本视图中间放置按钮_Android_Button_Textview_Android Linearlayout - Fatal编程技术网

Android 如何在文本视图中间放置按钮

Android 如何在文本视图中间放置按钮,android,button,textview,android-linearlayout,Android,Button,Textview,Android Linearlayout,我试图让两个android按钮出现在两个文本视图之间。但是第一个文本视图似乎正在显示,而其他文本视图和按钮则没有显示。我希望它看起来像: “诸如此类诸如此类诸如此类诸如此类诸如此类诸如此类诸如此类诸如此类诸如此类按钮诸如此类诸如此类诸如此类诸如此类按钮” 我看到的是: “诸如此类诸如此类诸如此类诸如此类诸如此类诸如此类诸如此类诸如此类” 代码如下: <LinearLayout android:layout_width="fill_parent" android:layout_hei

我试图让两个android按钮出现在两个文本视图之间。但是第一个文本视图似乎正在显示,而其他文本视图和按钮则没有显示。我希望它看起来像:

“诸如此类诸如此类诸如此类诸如此类诸如此类诸如此类诸如此类诸如此类诸如此类按钮诸如此类诸如此类诸如此类诸如此类按钮”

我看到的是:

“诸如此类诸如此类诸如此类诸如此类诸如此类诸如此类诸如此类诸如此类”

代码如下:

<LinearLayout android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView 
        android:text="Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah "
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <Button
        android:text="BUTTON"
        android:background="@null"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView 
        android:text=" blah blah blah blah blah blahblah blah blah blah blah blah "
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <Button
        android:text="BUTTON"
        android:background="@null"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>


任何帮助都将不胜感激

您最好使用布局权重或相对布局来实现所需

有关布局的更多信息,请查看此项


请尝试下面的代码,并记住,如果“宽度”属性设置为“填充父对象”,则“权重”属性设置为1的控件将根据其宽度进行同等调整

<LinearLayout android:layout_width="fill_parent"
    android:orientation="horizontal" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent">
    <TextView 
        android:text="Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah "
        android:layout_height="wrap_content" android:layout_weight="1" android:layout_width="fill_parent"/>
    <Button
        android:text="BUTTON"
        android:background="@null"
        android:layout_height="wrap_content" android:layout_weight="1" android:layout_width="fill_parent" android:textColor="#ffffff"/>
    <TextView 
        android:text=" blah blah blah blah blah blahblah blah blah blah blah blah "
        android:layout_height="wrap_content" android:layout_weight="1" android:layout_width="fill_parent"/>
    <Button
        android:text="BUTTON"
        android:background="@null"
        android:layout_height="wrap_content" android:layout_weight="1" android:layout_width="fill_parent" android:textColor="#ffffff"/>
</LinearLayout>


您可以轻松地将“布局宽度”属性设置为“dp”值


关于代码的另一件事不是为了你的问题。为了清楚地表达您的问题,您可以在这里使用带有值的“android:text”属性。但如果不是,这是一种糟糕的做法。尝试将您的字符串值始终放在“strings.xml”文件中,您可以在“values”目录下找到该文件。

Hi Serdar,感谢您的快速响应,您能否提供一个如何使用布局权重实现我想要的结果的示例?请查看此链接,这是您的最佳示例。