掌握自定义ScrollView

发布于 2024-11-29 12:51:38 字数 1640 浏览 0 评论 0原文

ScrollView http://dl.dropbox.com/u/3216968/ScrollView%20problem .png

我有一个包含 LinearLayout 的 ScrollView。我有两个想要实现的自定义。

[1] 如何去除顶部的黑色阴影? 尝试查看 为什么我的List是黑色的Android但这只是针对ListView并谈论背景。

[2] 当我尝试为 LinearLayout 制作摇动动画时,动画不会显示在线条之外。尝试了很多不同的事情,但开始认为这是不可能的。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/ScrollView_response"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:scrollbars="vertical"
  android:scrollbarAlwaysDrawVerticalTrack="true"
  android:background="@color/transparent"
  android:fillViewport="true"
  android:fadingEdge="none" >

<LinearLayout android:id="@+id/LinearLayout_response"
    android:background="@drawable/background_red"
    android:orientation="vertical" 
    android:layout_width="match_parent" android:layout_height="match_parent"
    android:minWidth="270dp"

    >

这是活动代码

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.manual_resonse_layout);

    Animation shakeIn = AnimationUtils.loadAnimation(this, R.anim.shake_in);
    LinearLayout mainView = (LinearLayout) findViewById(R.id.LinearLayout_response);

    mainView.startAnimation(shakeIn);

ScrollView http://dl.dropbox.com/u/3216968/ScrollView%20problem.png

I have a ScrollView that contains a LinearLayout. I have two customizations I want to implement.

[1]
How to I remove the black shadow on the top?
Tried to look at Why is my List black Android but that is only for the ListView and talking about the background.

[2]
When I try to make a shake animation for the LinearLayout the animation is not showing outside the lines. Have tried so many different things and are beginning think is not possible.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/ScrollView_response"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:scrollbars="vertical"
  android:scrollbarAlwaysDrawVerticalTrack="true"
  android:background="@color/transparent"
  android:fillViewport="true"
  android:fadingEdge="none" >

<LinearLayout android:id="@+id/LinearLayout_response"
    android:background="@drawable/background_red"
    android:orientation="vertical" 
    android:layout_width="match_parent" android:layout_height="match_parent"
    android:minWidth="270dp"

    >

This is the Activity code

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.manual_resonse_layout);

    Animation shakeIn = AnimationUtils.loadAnimation(this, R.anim.shake_in);
    LinearLayout mainView = (LinearLayout) findViewById(R.id.LinearLayout_response);

    mainView.startAnimation(shakeIn);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

や三分注定 2024-12-06 12:51:38

至于顶部的“黑色阴影”,将 ScrollView android:fadingEdge XML 属性设置为“none”即可。

As for the "black shadow" on top, setting the ScrollView android:fadingEdge XML attribute to "none" should do.

旧人 2024-12-06 12:51:38

为了使摇动动画起作用,您的线性布局需要设置一些边距,以便它有足够的“空间”来摇动。您可以使滚动视图填充屏幕的宽度,并使线性布局变小并放置在中间等。

至于阴影,这是一个好问题!

In order that shake animation works, your linear layout need to have some margins set so that it has enough "room" to shake around. You can make your scroll view to fill the width of the screen and the linear layout smaller and placed in the middle etc.

As for the shadow, that is a good question!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文