首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

statckoverflow里关于RelativeLayout不错的一个格局

2012-09-29 
statckoverflow里关于RelativeLayout不错的一个布局Question:RelativeLayout is your friend whenever you

statckoverflow里关于RelativeLayout不错的一个布局


Question:

RelativeLayout is your friend whenever you are aligning text to a particular edge.Use the padding settings to put text "a little away from" an edge.Gravity aligns the text within that TextView or button.

Looking again I your diagram, I reproduced it this way:

    Start with a relative layout ('fill_content') that takes up the entire screen.Put in the "short text" and "some more text" by anchoring to the top and bottom.Put a zero-width item with the property "centerInParent" for a point in the middle of the screen.Put the remaining to items above and aligned with that centerpoint.

Unfortunately, nothing in step 4 worked correctly. Nothing like "layout_below" worked when the referenced item was a centerInParent item. with relative layouts to step 3. Turns out it had to do with failing to fill_content on the top level. Yes, the layouts are tricky, and I wish there was a debugger for them.

Here's the correct version:

 <TextView android:id="@+id/centerpoint"    android:layout_centerInParent="true"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:width="0dip"    android:height="0dip"    />
?

热点排行