Android - LinearLayout in ScrollView in Relativelayout

一曲冷凌霜 提交于 2019-12-06 03:47:48

Ok, I've made it. All I had to do is setting LinearLayout that is inside of ScrollView to

layout_width="wrap_content"
layout_gravity="center_horizontal"
android:orientation="vertical"

The ScrollView to

layout_width="fill_parent"
layout_gravity="center_horizontal"
layout_height="wrap_content"

And at the end I've put that ScrollView into new LinearLayout with parameters as following:

layout_width="fill_parent" 
layout_height="fill_parent" 
gravity="center_vertical" 
orientation="vertical"

So the ScrollView and it's child Layout are setting buttons center horizontaly and the outer LinearLayout is setting them center verticaly. :-)

Sashi Kolli

Try changing the layout_width of lin2 to wrap_content instead of fill_parent.

try this code i think this is the best sollution

  <HorizontalScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent" android:orientation="vertical" >
   </HorizontalScrollView>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!