在这篇文章中,我们将为您详细介绍如何在Android中垂直滚动活动的内容,并且讨论关于安卓fragment垂直滑动的相关问题。此外,我们还会涉及一些关于androidlistview水平滚动和垂直滚动
在这篇文章中,我们将为您详细介绍如何在Android中垂直滚动活动的内容,并且讨论关于安卓fragment垂直滑动的相关问题。此外,我们还会涉及一些关于android listview 水平滚动和垂直滚动的小例子、Android TabHost Auto在TabChange的侧面ScrollView中垂直滚动?、android – 在ViewPager中垂直滚动页面、android – 如何制作水平和垂直滚动的二维图库?的知识,以帮助您更全面地了解这个主题。
本文目录一览:- 如何在Android中垂直滚动活动(安卓fragment垂直滑动)
- android listview 水平滚动和垂直滚动的小例子
- Android TabHost Auto在TabChange的侧面ScrollView中垂直滚动?
- android – 在ViewPager中垂直滚动页面
- android – 如何制作水平和垂直滚动的二维图库?
如何在Android中垂直滚动活动(安卓fragment垂直滑动)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:isScrollContainer="true"> <gallery android:id="@+id/gallery" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="bottom"/> <LinearLayout android:id="@+id/chart" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" /> </LinearLayout>
在运行时填充图库,当用户点击某个项目时,我会用一系列图像填充LinearLayout.
我想垂直滚动,但如果我在用户点击图库时添加ScrollView,则不再填充LinearLayout.
这是正常的吗?如何添加垂直滚动?
谢谢和问候
C.
解决方法
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ScrollView android:id="@+id/ScrlView" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:id="@+id/layoutForScroll" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" > <gallery android:id="@+id/gallery" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="bottom"/> <LinearLayout android:id="@+id/chart" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" /> </LinearLayout> </ScrollView> </LinearLayout>
android listview 水平滚动和垂直滚动的小例子
网上有很多解决 android listview 水平和垂直滚动的代码,我没有按照他们说的做(以前没搜到 O(∩_∩)O~) 我采用的是添加horizontalscrollviewJava代码
< ScrollView android:id="@+id/ScrollView01"
android:layout_height="300px"
android:layout_x="16px"
android:layout_y="84px"
android:layout_width="290px"
android:scrollbars="horizontal|vertical">
< horizontalscrollview android:id="@+id/horizontalscrollview01"
android:layout_height="fill_parent"
android:layout_width="wrap_content">
< LinearLayout android:id="@+id/LinearLayout02"
android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_height="fill_parent">
< ListView android:id="@+id/listview"
android:layout_height="300px"
android:layout_width="fill_parent">
< /ListView>
< /LinearLayout>
< /horizontalscrollview>
< /ScrollView>
Android TabHost Auto在TabChange的侧面ScrollView中垂直滚动?
我在我的Activity中使用ScrollView中的TabHost但是当我选择tab时它会自动垂直滚动我的视图结束.
解决方法:
在这种情况下,子视图由于向上滚动而获得焦点.
要解决此问题,您需要创建扩展ScrollView的自定义ScrollView.
代码片段看起来像这样.
public class MyScrollView extends ScrollView {
public MyScrollView(Context context) {
super(context);
}
public MyScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void requestChildFocus(View child, View focused) {
// if (focused instanceof TabHost) // here
return;
//super.requestChildFocus(child, focused);
// here you need to return instead of **super.requestChildFocus(child, focused);**
}
和xml看起来像这样
<com.views.widget.MyScrollView
android:focusable="false"
android:focusableInTouchMode="false"
android:id="@+id/root_scroll_view"
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="wrap_content">
</com.views.widget.MyScrollView >
android – 在ViewPager中垂直滚动页面
layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v4.view.ViewPager android:id="@+id/conpageslider" android:layout_width="match_parent" android:layout_height="match_parent"/> </LinearLayout>
滚动查看器类
public class ScrollingViewPager extends Activity{ private ViewPager pager; private Context cxt; private CharSequence[] pages = {"stuff","more stuff","other stuff"}; private PageSlider ps; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.layout); cxt = this; ps = new PageSlider(); pager = (ViewPager) findViewById(R.id.conpageslider); pager.setAdapter(ps); } public class PageSlider extends PagerAdapter{ @Override public int getCount() { return pages.length; } @Override public Object instantiateItem(View collection,int position) { ScrollView sc = new ScrollView(cxt); sc.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); sc.setFillViewport(true); TextView tv = new TextView(cxt); tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); tv.setText(pages[position]); tv.setPadding(5,5,5); sc.addView(tv); ((ViewPager) collection).addView(sc); return sc; } @Override public void destroyItem(View collection,int position,Object view) { ((ViewPager) collection).removeView((ScrollView) view); } @Override public boolean isViewFromObject(View view,Object object) { return view==((ScrollView)object); } } }
我可以批评代码,但至少这里是一个功能的例子
解决方法
android – 如何制作水平和垂直滚动的二维图库?
我发现了一个关于如何显示图像列表here的有用帖子.我想知道是否可以在图库视图中嵌套图像列表?
解决方法
~Aedon
总结
以上是小编为你收集整理的android – 如何制作水平和垂直滚动的二维图库?全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
今天关于如何在Android中垂直滚动活动和安卓fragment垂直滑动的介绍到此结束,谢谢您的阅读,有关android listview 水平滚动和垂直滚动的小例子、Android TabHost Auto在TabChange的侧面ScrollView中垂直滚动?、android – 在ViewPager中垂直滚动页面、android – 如何制作水平和垂直滚动的二维图库?等更多相关知识的信息可以在本站进行查询。
本文标签: