【发布时间】:2013-06-29 05:24:57
【问题描述】:
我想请你帮忙设置我的 ImageView 的正确宽度。我的 ImageView 有一个动画,它的宽度遍布我的显示器。我只需要大约 50dp 的宽度,而不是更多。
我的ImageView:
<?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:background="@color/darkgrey" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/image"
android:layout_width="50dp"
android:layout_height="200dp"
android:contentDescription="@string/imgdesc"
android:padding="15dp" />
</TableLayout>
</ScrollView>
动画 XML - anim_lytkove_vyskoky.xml:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false"
android:id="@+id/kat1_lytkove_vyskoky" >
<item
android:drawable="@drawable/kat1_lytkove_vyskoky_1"
android:duration="500" />
<item
android:drawable="@drawable/kat1_lytkove_vyskoky_2"
android:duration="500" />
</animation-list>
【问题讨论】:
-
sp仅用于文本,图像应使用dp或dip -
@AndersonSilva:好的,谢谢,但是我的问题呢?它还在那里
-
您应该显示更多代码,我刚刚运行了一个与您的示例一样的示例并且工作正常。检查一下,看看你是否遗漏了什么developer.android.com/reference/android/graphics/drawable/…
-
@AndersonSilva:我应该添加哪部分代码?在 java 代码中,我得到了您发布的链接中的确切内容。它可以工作,但是它太宽了,我只需要缩小动画的宽度。
标签: android animation imageview width