我有两个文本浏览,我想根据空间将第二个文本视图向右或第一个文本视图的底部对齐。结果应该是这样的:根据空间将文本向右或向下对齐
第一种情况(单线):
文本1一行文本2
第二种情况(多线):
文本1例如用
两行
___________Text2
正如你所看到的,在第一种情况下,第二个textv视图与右侧对齐,而在第二种情况下,它与右侧和底部对齐。我怎么能在XML中实现这个结果?
在此先感谢!
我有两个文本浏览,我想根据空间将第二个文本视图向右或第一个文本视图的底部对齐。结果应该是这样的:根据空间将文本向右或向下对齐
第一种情况(单线):
文本1一行文本2
第二种情况(多线):
文本1例如用
两行
___________Text2
正如你所看到的,在第一种情况下,第二个textv视图与右侧对齐,而在第二种情况下,它与右侧和底部对齐。我怎么能在XML中实现这个结果?
在此先感谢!
您可以使用FlowLayout
ViewGroup
作为父项。
什么你的意思是文本1大于屏幕?
这是我写的示例代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:background="@android:color/holo_green_dark"
android:layout_height="wrap_content">
<TextView
android:layout_weight="1"
android:gravity="bottom|left"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="your text more than 1 line"/>
<TextView
android:gravity="center|bottom"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Text2"/>
</LinearLayout>
以适应文本1左,文本2是正确的,使用LinearLayout
并设置orientation:"horizontal"
让我知道,如果这没有回答你想要的。
与您的问题相关,您只需要玩TextView
的gravity
如果Textview
的值为动态,则必须在您的java文件中创建条件。
你是什么意思,Text1放大那个屏幕? –