www.91084.com

GVKun编程网logo

如何在Android中垂直滚动活动(安卓fragment垂直滑动)

8

在这篇文章中,我们将为您详细介绍如何在Android中垂直滚动活动的内容,并且讨论关于安卓fragment垂直滑动的相关问题。此外,我们还会涉及一些关于androidlistview水平滚动和垂直滚动

在这篇文章中,我们将为您详细介绍如何在Android中垂直滚动活动的内容,并且讨论关于安卓fragment垂直滑动的相关问题。此外,我们还会涉及一些关于android listview 水平滚动和垂直滚动的小例子、Android TabHost Auto在TabChange的侧面ScrollView中垂直滚动?、android – 在ViewPager中垂直滚动页面、android – 如何制作水平和垂直滚动的二维图库?的知识,以帮助您更全面地了解这个主题。

本文目录一览:

如何在Android中垂直滚动活动(安卓fragment垂直滑动)

如何在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 水平滚动和垂直滚动的小例子

网上有很多解决 android listview 水平和垂直滚动的代码,我没有按照他们说的做(以前没搜到 O(∩_∩)O~) 我采用的是添加horizontalscrollview
Java代码
复制代码 代码如下:

 < 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中垂直滚动?

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中垂直滚动页面

android – 在ViewPager中垂直滚动页面

这可能是显而易见的,并且是一个完全不必要的帖子,但是我一直在解决一个方法来允许在VewPager中的页面上进行垂直滚动功能,而且谷歌甚至这里甚至没有什么决议.我发现一些人声称要解决这个问题,但似乎有所扩大和复杂.所以对于那些可能在寻找同样的问题的人来说,解决方案.有了这个(你会想要比我在这里写的更大的字符串),你将能够垂直滚动内容并在页面之间滑动.

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);
    }

}
}

我可以批评代码,但至少这里是一个功能的例子

解决方法

我做了类似的在分页器中使用片段. tabWigdet可以显示或不显示. 该示例包含在android-support-v4演示应用程序中.

android – 如何制作水平和垂直滚动的二维图库?

android – 如何制作水平和垂直滚动的二维图库?

我是 Android的新手,我想创建一个图像库,其中每列都是一个类别,用户可以垂直和水平滚动.

我发现了一个关于如何显示图像列表here的有用帖子.我想知道是否可以在图库视图中嵌套图像列表?

解决方法

将一个库放入一个GridView中,其中一列和列大小设置为填充父视图(或该效果的某些内容).将一个库放入GridView,并将其在LayoutParams中的高度设置为您想要占用它们的drawable / views的高度.您需要做的就是移动一个库以在网格视图中移动所有其他库.我将在下面发布代码.注意:我所做的代码是一个有效的概念测试,我只是在手机上试了一下.因此,它并不浮华.当我继续研究它时,我可能会更新代码以使其看起来更好.

~Aedon

总结

以上是小编为你收集整理的android – 如何制作水平和垂直滚动的二维图库?全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

今天关于如何在Android中垂直滚动活动安卓fragment垂直滑动的介绍到此结束,谢谢您的阅读,有关android listview 水平滚动和垂直滚动的小例子、Android TabHost Auto在TabChange的侧面ScrollView中垂直滚动?、android – 在ViewPager中垂直滚动页面、android – 如何制作水平和垂直滚动的二维图库?等更多相关知识的信息可以在本站进行查询。

本文标签:

上一篇Android:Listview没有使用键盘(android listview按钮点击)

下一篇Android – 在我的应用程序中获取电子邮件附件名称(获取电子邮件地址)