【问题标题】:Android - How to set width of <animation-list> or <item>s in it?Android - 如何在其中设置 <animation-list> 或 <item> 的宽度?
【发布时间】: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 仅用于文本,图像应使用dpdip
  • @AndersonSilva:好的,谢谢,但是我的问题呢?它还在那里
  • 您应该显示更多代码,我刚刚运行了一个与您的示例一样的示例并且工作正常。检查一下,看看你是否遗漏了什么developer.android.com/reference/android/graphics/drawable/…
  • @AndersonSilva:我应该添加哪部分代码?在 java 代码中,我得到了您发布的链接中的确切内容。它可以工作,但是它太宽了,我只需要缩小动画的宽度。

标签: android animation imageview width


【解决方案1】:

摆脱TableLayout(或将其切换为TableRow

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/darkgrey" >

    <TableRow
            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/content_desc"
                android:padding="15dp" />
    </TableRow>

</ScrollView>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-28
    • 1970-01-01
    • 2015-12-14
    • 2012-09-30
    • 2017-02-01
    • 2017-02-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多