如何将按钮放置在 Textview 的中间
我试图让两个 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>
任何帮助将不胜感激!
I am trying to get two android buttons to appear inbetween two textviews. But the first textview seems to be showing while the other textview and buttons are not appearing. I want it to look like:
"Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah BUTTON blah blah blah blah blah blahblah blah blah blah blah blah BUTTON"
What I am seeing is:
"Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah "
Here is the code:
<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>
Any help would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您最好使用布局权重或相对布局来实现您想要的。
检查此以获取有关布局的更多信息。
http://developer.android.com/guide/topics/ui/layout -objects.html
You better use layout weights or relative layout to achieve what you want.
Check this for more info on layouts.
http://developer.android.com/guide/topics/ui/layout-objects.html
则权重属性设置为 1 的控件将根据其宽度进行同等调整
尝试下面的代码并记住,如果宽度属性设置为 Fill_parent
try below code and remember that controls having weight property set as 1 will be equally adjusted accroding to their width if width property set to Fill_parent
您可以轻松地提供“布局宽度”属性作为“dp”值。
关于您的代码的另一件事不适合您的问题。您可能在此处使用了“android:text”属性和值,以便清楚地表达您的问题。但如果没有,这是一个不好的做法。尝试将字符串值始终放在“strings.xml”文件中,您可以在“values”目录下找到该文件。
You can go easily with providing "Layout width" attribute as "dp" value.
One other thing about your code not for your question. You may have use "android:text" attributes with values in here in order to clearly express your question. But if not, this is a bad practice. Try to put your String values always in the "strings.xml" file where you can find under the "values" directory.