相关疑难解决方法(0)

如何在具有多个列表视图的android中构建复杂的布局

我们正在与我们想融入后的详细视图多个组件的应用程序工作(见样机.)每件的可扩展(通常使用Ajax调用)和整个屏幕滚动查看全部内容.

listview样机

我们不确定解决此问题的最佳方法,因为根据Google的说法,列表视图不应放在滚动视图中.似乎有人这样做,因为如何将ListView放入ScrollView而不会崩溃?.

一般来说,帖子中的内容量足够小,可以一次性全部膨胀,但有可能获得100多张照片或300多条评论的帖子,其中内存可能是一个问题.

我的问题是建立这样一个布局的最好的方法是什么,如果不是正式的话.我有兴趣听听整个布局结构的建议,所以我理解像标题这样的静态内容如何与照片或评论一起播放.

我想优化小帖子的性能/易于实现(几张照片,20-50条评论) - 但我们必须能够处理大型帖子而不会崩溃应用程序.

android listview android-layout

7
推荐指数
1
解决办法
3992
查看次数

在ScrollView中滚动ListView的问题

这是概念上的场景(不包括linearlayouts)

ScrollView
  Button
  Checkboxes
  Spinner
  ListView (full-size, non-scrolling)
AdMob advert
Run Code Online (Sandbox Code Playgroud)

即滚动窗格,其顶部有过滤UI,后跟结果,但广告必须始终保持可见,向下滚动过滤器UI必须滚动,留出最大的结果空间.

我知道ScrollView中的ListView存在问题,但对我而言,它在很多方面都运行良好(我正在修复ListView的长度以阻止它崩溃).因此屏幕滚动得很好,广告保持在底部,看起来不错.

但是我看到的问题莫名其妙地,当活动打开时,ScrollView向下滚动了一下,因此ListView位于屏幕的顶部.我假设这是一个默认行为,所以我开始尝试强制ScrollView的滚动位置到顶部,但我尝试了各种方法,并看不到任何效果:

scrollview.scrollTo(0, 1000/-1000);
scrollview.smoothScrollBy(0, 1000/-1000);
scrollview.fullScroll(View.FOCUS_UP);
Run Code Online (Sandbox Code Playgroud)

有没有办法强制ScrollView从顶部的滚动位置开始?

如果没有,我怎么能有一个不滚动底部的广告,但是一个总是滚动到顶部的过滤器UI?使用ListView似乎有些过分,因为我不需要滚动,但它确实提供了许多好处,所以最好避免从头开始并自己渲染所有内容.

android

6
推荐指数
1
解决办法
4200
查看次数

在三星Galaxy Tab 2.3.3 android上禁用listview过度滚动

我需要完全禁用listview中的过度滚动,这样我就可以实现自己的过度滚动功能.

通过将overscroll模式设置为OVERSCROLL_NEVER ,在查看核心listview类时似乎很简单.这个很好的工作在我的三星Galaxy s2上.但不起作用Galaxy Tab 2.3.3.

有没有人对三星ListView自定义有很多经验可以帮助我?

android

6
推荐指数
1
解决办法
1798
查看次数

将ScrollViews布局用于Horizo​​ntalScrollView

我想用卡片创建一种卡片布局,其中包含一个可以水平滚动卡片的ListView布局HorizontalScrollableView.一切正常,但我有滚动问题.只有当我没有水平滚动卡片时才能垂直滚动列表视图而反之亦然.

这是主要的容器:

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

    <HorizontalScrollView
        android:id="@+id/listview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#ddd" >

        <LinearLayout
            android:id="@+id/list"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:orientation="horizontal" >
        </LinearLayout>
    </HorizontalScrollView>



</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我膨胀并将listview项添加到线性布局.我想平滑地进行垂直和水平滚动,没有这些限制(同时水平和垂直滚动).

我怎样才能做到这一点?

android horizontalscrollview android-listview

6
推荐指数
1
解决办法
1947
查看次数

ScrollView> LinearLayout> PreferenceFragment为零高度

我有一个活动,它有一个带有垂直LinearLayout的ScrollView,它有两个片段,它们是PreferenceFragment实例,如下面的布局文件所示:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="wrap_content"
android:layout_width="match_parent"
>

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:context="com.foo.app.SettingsActivity">

    <fragment
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:name="com.foo.app.SettingsFragment"
        android:id="@+id/fragment_settings"/>

    <fragment
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:name="com.foo.app.NotificationSettingsFragment"
        android:id="@+id/fragment_notification_settings"/>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

问题是这两个片段只显示了他们的PreferenceCategory标题,而实际的片段UI是零高度且不可见.奇怪的是,可以单独滚动每个片段并查看丢失的片段UI.就好像每个Fragment都在ScrollView中.

我期望的是两个片段的大小可以包装它们的内容,并且有一个垂直滑块可以滚动包含两个片段的LinearLayout.

如果它是相关的,这两个片段扩展android.preference.PreferenceFragment并且不在布局文件中定义它们的布局.相反,他们加载他们的Preference UI如下:

    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.pref_notification);
}
Run Code Online (Sandbox Code Playgroud)

TIA的帮助.

android scrollview android-linearlayout preferencefragment

6
推荐指数
2
解决办法
1778
查看次数

如何使FrameLayout填充其父级的高度,以便整个页面一起滚动?

我有一个FrameLayout加载Fragments通过点击一个标签TabWidget.我无法弄清楚如何使高度FrameLayout与其内容一样高,以便整个包含ScrollView将一起滚动而不是单独的滚动视图.

这是这个Fragment结构的一个直观的例子:

在此输入图像描述

正如您所看到的,帧布局可见高度仅显示片段的一行,而实际上有一些.我可以在其中滚动FrameLayout以查看现在的其他行,但这不是我想要的.该FrameLayout由一个LinearLayout包含GridView与他们的layout_heightS设定到wrap_content.

我尝试将其高度硬编码为FrameLayout类似于500dp的东西,除了它不再动态调整大小外,它的效果很好.FrameLayout每次将新图像加载到内部内容中时,是否需要以编程方式调整大小?是否有我可以设置的布局属性,因此它会拉伸其高度以匹配其内部内容?

这是我的布局xml文件:

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

    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="200dp">
        <!-- CONTAINS USER INFO AND STATS -->
    </RelativeLayout>
    <android.support.v4.app.FragmentTabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#ffffff">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="60dp"
                android:weightSum="2">
            </TabWidget>
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                >
            </FrameLayout>
        </LinearLayout>
    </android.support.v4.app.FragmentTabHost>
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

谢谢!


既然我要为此设置赏金,我想我会分享到目前为止我已经想到的东西. …

android

6
推荐指数
1
解决办法
5468
查看次数

我怎样才能在NestedScrollView中有一个ListView

我创建了一个带有页面的应用程序,需要从Web服务动态加载内容.我希望listview能够与NestedScrollView中的线性布局一起滚动.但是当内容加载到列表视图时,它不会延伸到其完整高度.

这是我的代码.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.myquestionth.myquestionth10.Profile2Activity"
    tools:showIn="@layout/activity_profile2">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="400dp"
                android:background="#BBBBBB" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="Media heading"
                android:id="@+id/textView2" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis."
                android:id="@+id/textView8" />

        </LinearLayout>

        <ListView
            android:id="@+id/listView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#70bcf5" />

    </LinearLayout>

</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

我有一些关于scrollview的搜索无法嵌套.根据我在Google Play评论页面设计的布局,这是我想要的一个例子.他们使用的方法是什么?建议我,如果我做错了什么.非常感谢.

在此输入图像描述

这就是我想要的.

在此输入图像描述

java layout android listview android-nestedscrollview

6
推荐指数
2
解决办法
1万
查看次数

尽管在恢复应用程序时某些项目已添加到适配器,但ListView为空

我在市场上有一个应用程序,我似乎无法解决这个问题.今天我跟踪了以下方法.

public void updateDealList(ArrayList<Deal> deals) {
    // first call or showing bookmakrs (also gets called other times when adapter is null)
    if (dealListAdapter == null || showingBookmarks || !dealListAdapter.moreDealsToDownload()) { 
        dealListAdapter = new EndlessDealListAdapter(getActivity(),
                R.layout.deal_list_item, deals);
        setListAdapter(dealListAdapter);
        listView = getListView();
        if (getActivity().findViewById(R.id.right_fragment_container)!=null){ // if tablet
            listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
            listView.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_LEFT);
        }
        showingBookmarks=false;
        Log.d("UPDATE_DEAL_LIST", "Notified list  created new" + dealListAdapter.getCount());
        return; //PROBLEM OCCURS WHEN APP COMES IN HERE AFTER RESUMING
    }
    dealListAdapter.getDealListAdapter().clear();
    for (Deal d: deals){
        dealListAdapter.getDealListAdapter().add(d);
        Log.d("UPDATE_DEAL_LIST", "added " + d.title);
    }
    dealListAdapter.notifyDataSetChanged(); …
Run Code Online (Sandbox Code Playgroud)

android android-listview android-adapter android-listfragment

5
推荐指数
1
解决办法
2642
查看次数

滚动视图中列表视图的滚动功能

在滚动视图中的我的应用程序中,我使用列表视图.但列表视图不滚动.任何人都可以建议我该怎么做.我搜索了它,发现列表视图不在滚动视图中滚动.
有解决方案吗

android listview scrollview

5
推荐指数
2
解决办法
2707
查看次数

键盘覆盖屏幕而不是推高布局?

我有一个问题,当我点击我的键盘时,我的屏幕内容没有被推高 - 而键盘只是重叠ListView了我屏幕上的所有内容(即覆盖我).这是我的布局结构:

<ScrollView>
  <RelativeLayout>
  </RelativeLayout>
</ScrollView>
<ListView>
</ListView>
<LinearLayout>
  <EditText></EditText>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我把我嵌套RelativeLayout在一个ScrollView因为我认为这将使我的整个布局可滚动,这将"推高"所有布局,以便用户可以在键入他或她的响应时查看这些部分.我也有我的AndroidManifest.xml:android:windowSoftInputMode="adjustResize|stateVisible|stateAlwaysHidden"这是一个正在发生的事情的图像:

正在发生的事情的形象

这是我的代码.任何帮助,将不胜感激!

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" android:fitsSystemWindows="true"
    xmlns:fresco="http://schemas.android.com/tools"
    android:id="@+id/comments_coordinator_layout">

<android.support.design.widget.AppBarLayout
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/comments_appbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/comments_coordinator_layout"
        >

        <RelativeLayout
            android:layout_marginTop="?attr/actionBarSize"
            android:id="@+id/view_post"
            android:layout_width="match_parent"
            android:paddingRight="5dp"
            android:paddingLeft="5dp"
            android:orientation="horizontal"
            android:layout_height="175dp"
            android:background="#e6e6e6">

            <com.facebook.drawee.view.SimpleDraweeView
                android:layout_marginTop="15dp"
                android:id="@+id/poster_picture"
                android:layout_width="75dp"
                android:layout_height="75dp"
                android:layout_marginLeft="10dp"
                fresco:placeholderImage="@mipmap/blank_prof_pic"
                fresco:roundedCornerRadius="5dp"
                />

            <TextView
                android:layout_marginLeft="5dp"
                android:layout_marginTop="15dp"
                android:layout_toRightOf="@id/poster_picture"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="15sp"
                android:textStyle="bold"
                android:id="@+id/poster_name"/>

            <TextView
                android:layout_alignParentRight="true" …
Run Code Online (Sandbox Code Playgroud)

android scrollview android-layout android-softkeyboard android-listview

5
推荐指数
1
解决办法
6090
查看次数