我一直在寻找这个问题的解决方案,我能找到的唯一答案似乎是" 不要将ListView放入ScrollView ".我还没有看到任何真正的解释为什么.我似乎找到的唯一原因是Google认为你不应该这样做.好吧,我做了,所以我做到了.
所以问题是,如何将ListView放入ScrollView而不将其折叠到最小高度?
我在滚动ListView里面遇到麻烦ScrollView.我有一个Activity在顶部有一些EditTexts,然后是一个带有两个选项卡的选项卡主机,每个选项卡都有一个ListView.当EditText视图聚焦时,软键盘出现,因为我有一个ScrollView,内容是可滚动的.但问题出现在ListViews中有更多项目(选项卡中的项目),即使有更多项目,我也无法滚动ListView.
以下是布局XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="?backgroundImage"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:layout_margin="10dip"
android:id="@+id/buttons">
<Button
android:text="Save"
android:layout_margin="2dip"
android:textSize="20dip"
android:id="@+id/btnSaveorUpdate"
android:layout_height="wrap_content"
android:layout_width="145dip"></Button>
<Button
android:text="Cancel"
android:layout_margin="2dip"
android:textSize="20dip"
android:id="@+id/btnCancelorDelete"
android:layout_height="wrap_content"
android:layout_width="145dip"></Button>
</LinearLayout>
<ScrollView
android:layout_above="@id/buttons"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:layout_margin="10dip">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dip">
<TextView
android:text="Bill details"
android:textColor="?textColorDark"
android:layout_alignParentTop="true"
android:id="@+id/txtEnterDetails"
android:textSize="25dip"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginBottom="2dip"></TextView>
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0dip"
android:layout_height="0dip" />
<EditText
android:layout_width="fill_parent"
android:hint="Enter data"
android:inputType="numberDecimal"
android:id="@+id/txtSample"
android:textSize="@dimen/editText"
android:layout_height="@dimen/editTextHeight"
android:text=""></EditText>
<EditText
android:layout_width="fill_parent"
android:id="@+id/txtDescription"
android:hint="Enter description"
android:textSize="@dimen/editText" …Run Code Online (Sandbox Code Playgroud) 我想为我的用户显示个人资料屏幕.
它必须有三个视图(2 Buttons和a ImageView)和a ListView以显示该用户所做的内容.
但是,我不想ListView滚动.相反,我希望它与所需的一样大,并将我的所有视图放在一个中ScrollView,所以三个第一个视图滚动出来ListView.当然,这不符合预期.
我的三件物品都在里面LinearLayout.我想把它们作为第一项ListView,但这导致它们可以作为第一项选择,并且不得不做一些不需要的编码.
有没有办法以简单的方式做到这一点,还是我必须坚持将布局作为ListView中的第一项?
我有一个ListView,我改变了行的外观,但listview的大小是一行,而不是全屏.
list_item.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView_news_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#0082A8" />
<TextView
android:id="@+id/textView_news_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
tab_news.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/list_news"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ListView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
制作适配器:
public class RSSAdapter extends ArrayAdapter<RSSitem> {
Context context;
int layoutResourceId;
ArrayList<RSSitem> data = null;
SimpleDateFormat sdf = new SimpleDateFormat("kk:mm ");
public RSSAdapter(Context context, int layoutResourceId, ArrayList<RSSitem> data) {
super(context, layoutResourceId, …Run Code Online (Sandbox Code Playgroud) 我有一个包含2个cardview的片段,其中包含多个控件.
在第二张cardview 下面我有一个recyclerview,这很完美.
问题是recyclerview从屏幕底部开始,滚动recylcerview非常小.
以前使用过listview,这使我保持适合你的内容,从而立即滚动屏幕,但recylclerview不能.
当我在recyclerview中滚动时,如何进行控制,就像视差效果一样?
编辑:更清楚,想象一个片段中的2张卡片,这些占据屏幕的80%,其中上面是一个带有100个项目列表的回收者视图,但是卷轴是如此微小......列表视图让我适应"内容"并立即滚动整个屏幕.
这是我的XML布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/svScroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<include
android:id="@+id/cvCampos1"
layout="@layout/ctlcabeceralibreta" />
<include
android:id="@+id/cvCampos2"
layout="@layout/ctlcabeceralibreta2" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rvRegistros"
android:layout_width="fill_parent"
android:layout_height="1000dp"
android:layout_below="@id/cvCampos2"
android:scrollbars="vertical" />
</RelativeLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
这是截图:

android android-appcompat android-layout android-cardview android-recyclerview
我有一个Android布局设置,我有一个ScrollView与一些元素,在里面,我有一个ListView.我在滚动视图中使用StackOverflow的答案Android列表视图来实现此功能,并且它工作正常.我的ListView位于TextView,ImageView等一些元素之下.问题是,当页面出现时,ListView会自动滚动,以便listView中的第一项位于顶部(即整个scrollview会滚动显示listview第一项).如何避免这种自动滚动?
我有一个ScrollView布局,里面有一个ListView.一切正常,但如果我打开DrawerLayout,ScrollView会滚动一点.只需看看这些截图.
在这里我打开DrawerLayout
你可以看到它滚动了一点.如何解决这个问题?这是我的xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/menuLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ProgressBar
android:id="@+id/progressWheelBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<TextView
android:id="@+id/noDataTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/noData"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone" />
<LinearLayout
android:id="@+id/actionBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/innerActionBarLayout"
android:layout_width="match_parent"
android:layout_height="55dp"
android:background="@color/material_blue_500" >
<ImageButton
android:id="@+id/menuButton"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:background="@null"
android:src="@drawable/ic_menu_white_24dp" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_toRightOf="@+id/menuButton"
android:textColor="@color/white"
android:textSize="18sp" />
</RelativeLayout>
</LinearLayout>
<ScrollView
android:id="@+id/mainScrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/actionBarLayout"
android:fillViewport="true"
android:scrollbars="none"
> …Run Code Online (Sandbox Code Playgroud) 我想要一个有2个ListView的Fragment.我不希望listView滚动而只是想让整个片段滚动.下面是代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff" >
<TextView
android:id="@+id/day"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="center_horizontal"
android:paddingTop="15dp"
android:text="Monday"
android:textColor="#000"
android:textSize="55sp" />
<TextView
android:id="@+id/date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/day"
android:gravity="center_horizontal"
android:text="27 April, 2014"
android:textColor="#000"
android:textSize="45sp" />
<ListView
android:id="@+id/home_list_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/date"
android:layout_margin="10dp"
android:background="@color/list_home_time_bg"
android:divider="@android:color/white"
android:dividerHeight="20.0sp" />
<ListView
android:id="@+id/home_list_stime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/home_list_time"
android:layout_margin="10dp"
android:background="@color/list_home_stime_bg"
android:divider="@android:color/white"
android:dividerHeight="20.0sp" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,第二个listView获得自己的滚动条,有没有办法停止这个并使整个片段滚动?
我正在实施一个RecyclerView内部ScrollView.为了在整个页面上只有一个滚动行为,我实现了一个NonScrollRecyclerView版本.实施如下:
public class NonScrollRecyclerView extends RecyclerView {
public NonScrollRecyclerView(Context context) { super(context); }
public NonScrollRecyclerView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NonScrollRecyclerView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev){
if(ev.getAction() == MotionEvent.ACTION_MOVE)
return true;
return super.dispatchTouchEvent(ev);
}
}
Run Code Online (Sandbox Code Playgroud)
一旦我将我的构建和目标设置更新到SDK 23,我就无法滚动包含该页面的页面NonScrollRecyclerView.具体问题是页面滚动正常,直到我到达回收站视图部分,一旦我滚动到此视图,我无法向上或向下滚动.
我不喜欢SDK 22及以下版本
我的xml如下:
XML @layout/rv包含回收器视图
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_gray">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background_gray"
android:orientation="vertical">
<include
layout="@layout/row_mall_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/cv_mall_header" …Run Code Online (Sandbox Code Playgroud) 我有一个问题,当我点击我的键盘时,我的屏幕内容没有被推高 - 而键盘只是重叠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
我试图DialogFragment弹出并显示可滚动TextView图例,但它只是切断了图例的其余部分。我无法滚动浏览它或任何东西。我尝试添加 aScrollView但它没有任何作用。这是我得到的屏幕:
这是我的 XML 布局文件:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbars="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:background="#fff">
<TextView
android:id="@+id/layer_legend_title_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="#fff"
android:textColor="#000" />
<ListView
android:id="@+id/layer_legend_symbols_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:background="#fff"
android:textColor="#000" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我运行此命令将内容添加到TextView:
/**
* A dialog that shows the legend of a ArcGISDynamicMapServiceLayer.
*/
public class LegendDialogFragment extends DialogFragment implements View.OnClickListener {
public static final String TAG = LegendDialogFragment.class.getSimpleName();
private LinearLayout mLinearLayout;
private ArcGISDynamicMapServiceLayer …Run Code Online (Sandbox Code Playgroud) android arcgis android-layout android-scrollview android-dialogfragment
我想在使用actionbarsherlock lib实现的Navigationdrawer中的片段中使用listview.问题是listView高度没有缩放到match_parent.它被扩展到listview的一项.我搜索了很多,尝试了类似的问题,并尝试将父布局更改为Relative_layout,Linear_layout和Frame_layout.我没有得到我做错的事.如何缩放listView以获取布局的其余大小.
这就是它在编辑器中的样子

这就是它在应用程序中的外观.listView的大小缩放为一个项目.对于更多项目,我必须滚动该空间.

我的主要片段布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/body_background_green"
android:orientation="vertical"
android:padding="5dp" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="30dp"
android:text="@string/farmerlist"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/farmercode" />
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/farmercode"
android:inputType="number" >
<requestFocus />
</AutoCompleteTextView>
</LinearLayout>
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/transparent"
android:dividerHeight="2dp" >
</ListView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是项目布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:id="@+id/ll1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Code : " …Run Code Online (Sandbox Code Playgroud) 有人知道我的布局有什么问题吗?我不知道为什么我的 ListView 只显示一项。
布局.xml
<?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"
android:background="@color/grey_200"
android:paddingLeft="10dp"
android:paddingRight="10dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.rostata.alejo.vbmobileapp.ActivityResult"
tools:showIn="@layout/activity_home">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:id="@+id/one">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="0dp"
android:background="@color/White"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_marginTop="20dp"
app:cardCornerRadius="4dp"
app:cardElevation="2dp">
<RelativeLayout
android:id="@+id/relativeGridInside"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/White"
android:padding="10dp">
<RelativeLayout
android:id="@+id/headerThisNow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border_bottom">
<Button
android:id="@+id/btnCloseWordOfTheDay"
style="?android:attr/buttonStyleSmall"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/ic_window_close"
android:text="" />
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:fontFamily="sans-serif-light-bold"
android:text="Word of the Day"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/grey_700"
android:textSize="25sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" …Run Code Online (Sandbox Code Playgroud) android listview android-listview android-studio nestedscrollview