我在ScrollView中有一个RelativeLayout.我的RelativeLayout有android:layout_height="match_parent"
但是视图不占用整个大小,它就像一个wrap_content.
有没有办法让真正的fill_parent/match_parent行为?
我的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/top"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
android:src="@drawable/top" />
<ImageView
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/top"
android:scaleType="fitXY"
android:src="@drawable/headerbig" />
<ImageView
android:id="@+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/header"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:src="@drawable/logo" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom"
android:layout_below="@+id/logo"
android:background="@drawable/background" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/dashboard01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/dashboard02"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:src="@drawable/dashboard01"
android:visibility="visible" />
<ImageView
android:id="@+id/dashboard02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:src="@drawable/dashboard02" />
<ImageView
android:id="@+id/dashboard03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/dashboard02"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:src="@drawable/dashboard03"
android:visibility="visible" />
</RelativeLayout>
</ScrollView>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/logo"
android:layout_centerHorizontal="true" …
Run Code Online (Sandbox Code Playgroud) 我的Android应用程序有一个主WebView(从本地资源加载的HTML),我想使用整个屏幕宽度,并能够(垂直)可滚动.所以我在我的布局XML中将WebView包装在ScrollView中,但无论我做什么,我似乎都无法从滚动视图的右侧删除滚动条轨道.更糟糕的是,我似乎无法改变滚动条轨道的背景颜色.
该轨道占用大约10dp左右,这为WebView中的HTML带来了问题.我希望滚动条显示在 Web视图的顶部(iPhone风格,如果您知道我的意思).现在,您可以说"为什么不将您的HTML更改为10px更薄?",这是我的后备解决方案,但我宁愿不必这样做.
这是布局XML的相关片段,你会看到我已经尝试了我能找到的每个android:etc属性:
<ScrollView
android:id="@+id/deal_web_view_holder"
android:layout_below="@id/clock_bar_holder"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="false"
android:fadingEdge="none"
android:background="#02a7e9"
android:scrollbars="none"
android:scrollbarSize="0dp"
android:paddingRight="0dp"
android:scrollbarAlwaysDrawVerticalTrack="false"
android:scrollbarStyle="insideOverlay"
android:scrollbarTrackVertical="@drawable/scrollbar_track_vertical" >
<WebView
android:id="@+id/deal_web_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我的目标是平台2.1/API lvl 7,真的只是处理正常大小的显示,mdp,hdp和xhdp.
我的代码遇到了问题.我正在尝试移动UIScrollView
当我正在编辑时UITextField
应该被键盘弹出隐藏.
我现在正在移动主框架,因为我不知道如何在代码中"向上滚动".所以,我做了一些代码,它工作正常但是当我编辑一个UItextfield并且我切换到另一个UITextField
而没有按下"返回"按钮时,主视图变得非常了不起.
我NSLog()
用变量大小,距离和textFieldRect.origin.y 做了一个,如下所示.当我把两个UITextField
放在同一个地方(y原点)并且我做这个特别的'开关'(没有按回车)时,我得到相同的数字,而我的代码在第一次UITextField
编辑时工作正常但不适用于第二次编辑.
看一下这个:
- (void)textFieldDidBeginEditing:(UITextField *)textField {
{
int size;
CGRect textFieldRect = [self.view.window convertRect:textField.bounds fromView:textField];
size = textFieldRect.origin.y + textFieldRect.size.height;
if (change == FALSE)
{
size = size - distance;
}
if (size < PORTRAIT_KEYBOARD_HEIGHT)
{
distance = 0;
}
else if (size > PORTRAIT_KEYBOARD_HEIGHT)
{
distance = size - PORTRAIT_KEYBOARD_HEIGHT + 5; // +5 px for more visibility
}
NSLog(@"origin %f", textFieldRect.origin.y);
NSLog(@"size %d", …
Run Code Online (Sandbox Code Playgroud) 我希望scrollView中的内容为中心.
<ScrollView
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="12dp"
android:paddingBottom="20dp"
android:scrollbarStyle="outsideOverlay"
android:layout_gravity="center" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="check"
android:gravity="center_vertical|center_horizontal"/>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
注意:android:gravity
scrollvew 没有属性.
任何溶胶: -
我有一个"页面",其上有许多组件,其内容的长度超过了设备的高度.好吧,只需将所有布局(整个页面)放在里面ScrollView
,没问题.
其中一个组件是ViewPager
.这可以正确呈现,但是对滑动/拖动的响应没有正确执行,它是紧张的,并不总是有效.它似乎与'混淆' ScrollView
,所以当你在一条精确的水平线上投掷时,只能100%工作.
如果我删除了ScrollView
,ViewPager会完美响应.
我有一个搜索,并没有发现这是一个已知的缺陷.还有其他人经历过这个吗?
下面是一些示例代码供您测试,注释掉ScrollView
以查看它是否正常工作.
活动:
package com.ss.activities;
import com.ss.R;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;
public class PagerInsideScollViewActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ViewPager vp = (ViewPager) findViewById(R.id.viewpager);
vp.setAdapter(new MyPagerAdapter(this));
}
}
class MyPagerAdapter extends PagerAdapter {
private Context ctx;
public MyPagerAdapter(Context context) {
ctx = …
Run Code Online (Sandbox Code Playgroud) 我ScrollView
在Android中使用了一个,其中可见部分的ScrollView
大小与其中一个单元格的大小相同Scrollview
.每个"细胞"都是相同的高度.因此,我想要做的是ScrollView
在滚动后捕捉到位置.
目前我正在检测用户何时触摸,ScrollView
以及何时开始滚动并从那里开始工作,但它非常错误.当用户只是轻弹它并滚动然后减速时,它也需要工作.
在iPhone上有一个类似的功能,didDecelerate
在ScrollView
完成滚动后我可以做任何我想要的代码.Android有这样的东西吗?或者是否有一些我可以看到的代码来找出更好的方法呢?
我查看了Android文档,找不到类似的东西.
我正在尝试制作这样的布局:
问题是我不希望ListViews可滚动.我希望它们尽可能高,并使整个屏幕可滚动.如果我将ListView的高度设置为ListViews
,则不起作用.使它工作的唯一方法是设置一个特定的高度 - 但我不知道ListView中有多少项.
我知道我不应该将ListView放在ScrollView中 - 但我不希望ListView可以滚动,只是为了显示所有项目.
也许还有更好的方法让它发挥作用?
我必须设计布局,使整个布局应该滚动和内部布局我必须在Grid
表单中显示相关内容所以我决定使用GridView
.但问题是我无法在GridView
里面使用ScrollView
我已阅读文档(文档也说我们应该也不要GridView
在里面使用ScrollView
)但是我必须这样做,所以请任何关于此的请给我一些想法.谢谢
我正在尝试创建一个包含文本和图像的屏幕.我希望图像像网格一样布局,如下所示,但我希望它们没有周围ScrollView提供的滚动功能.
图像最能说明我的问题:
<ScrollView>
<LinearLayout>
<ImageView />
<TextView />
<GridView />
<TextView />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
什么是显示不同数量图像的网格的最佳方法,其中网格没有滚动功能?
请注意,禁用GridView的滚动功能不起作用,因为这只会禁用滚动条但不显示所有项目.
更新:下图显示了在GridView中禁用滚动条的情况.
我有一个ScrollView的问题,里面有个性化的GridView和其他视图.第一次启动Activity时,ScrollView从顶部开始,但是如果我访问Activity其他时候ScrollView从头开始GridView.I使用了此链接中为我的GridView 找到的类ExpandableHeightGridView .Activity布局的xml代码是这样的:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollViewLuogo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff" >
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="150dp"
android:layout_height="100dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:adjustViewBounds="true"
android:maxHeight="200dp"
android:maxWidth="200dp"
android:scaleType="fitXY"
android:src="@android:drawable/ic_menu_gallery" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<TextView
android:id="@+id/nomeTVActivityLuogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="17sp"
android:textColor="#005788" />
<TextView
android:id="@+id/indirizzoTVActivityLuogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/linearLayout2"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageViewMappaLuogo"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:layout_marginTop="5dp"
android:scaleType="fitXY"
android:src="@drawable/sfondo_mappa" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="14dp" …
Run Code Online (Sandbox Code Playgroud) scrollview ×10
android ×9
gridview ×3
cocoa-touch ×1
imageview ×1
ios ×1
iphone ×1
java ×1
layout ×1
objective-c ×1