English 中文(简体)
在布局中以另一个视图居中文本,以限制左侧大小
原标题:Center a text in layout limiting the left size with another view

让我解释一下, 需要按照父系家长的顺序, 将电流居中, 但考虑到对布局左侧的观察:

|------------Screen--------------|
[View]    [Short Text]

|------------Screen--------------|
[View][Loooooooooooooooooong Text]

使用相对布局重力属性 I only getting this:

|------------Screen--------------|
[View]       [Short Text]          <------THIS IS WRONG.

|------------Screen--------------|
[View][Loooooooooooooooooong Text]

提前感谢

问题是如何做出布局。 没有代码可以从它开始( 当然没有固定的视图宽度值), 我其实是相对的, 但是没有运气 。

现在,如果你真的想从头开始做点什么的话,

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center">
    <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_weight="0"
    android:src="@drawable/something" />
    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1" />
</LinearLayout>
问题回答

将您的 2 视图放在线性布局中

//使用 和机器人:布置_weight

for your view give weight as 0 for your shorttext view give weight as 1 and gravity as left.

这样行行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行,行





相关问题
Very basic WPF layout question

How do I get this listbox to be maxiumum size, i.e. fill the group box its in. I ve tried width="auto" Height="auto", width="stretch" Height="stretch" annoyingly at the moment, it dynamicly sizes to ...

How to align the text to top of TextView?

How to align the text to top of a TextView? Equivalent Android API for Swings setInsets()? that is top of text should start be in (0,0) of TextView <?xml version="1.0" encoding="utf-8"?> <...

Centring a flow in Shoes

Can I center the contents of a flow in Shoes? I know that a paragraph can be centred like: para Centred paragrpah , :align=> center However, this does not work with flows: flow(:align=> ...

Overlaying with CSS

I want to load a website in an iframe, and overlay the website with some hints about the website that is shown. However, i got stuck at the point that the website has a variable passive white space at ...

How do you normally make a program look beautiful? [closed]

How can I make an Application look nice and not like an amateur pulled it together? I mean graphic-wise. Is there some sort of book you can read regarding beautiful program layouts, etc? I put this ...

热门标签