Android - ImageView - Galaxy Tab 2上的黑色图像

时间:2015-07-23 13:08:49

标签: java android android-studio imageview galaxy-tab

我的应用程序在每个设备上都能正常工作,但Galaxy Tab 2除外。

这就是它在Galaxy Tab 2上的外观:

enter image description here

我已尝试过每一个解决方案,它仍然是相同的; /。

imageView.setImageResource(songsList.get(position).getIconId());< ---我在这里添加了正确的资源ID,它显示了一个黑色图像。

我甚至将我的图片复制到hdpi/xhdpi/xxhdpi/xxhdpi个文件夹,它们都是一样的。

任何人都知道这里有什么问题吗? ; S

我的适配器:

@Override
public View getView(int position, View view, ViewGroup parent) {
    if (view == null) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        view = inflater.inflate(R.layout.view_row, parent, false);
    }

    imageView = (ImageView) view.findViewById(R.id.list_image);
    imageView.setImageResource(songsList.get(position).getIconId());

    Log.i("SongBox", "" + songsList.get(position).getIconId());

    return view;
}

view_row:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="150dp"
    android:background="@android:drawable/dialog_holo_light_frame"
    android:orientation="vertical"
    android:padding="5dp">

    <ImageView
        android:id="@+id/list_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:contentDescription="@string/desc"
        android:scaleType="centerCrop" />

    <RelativeLayout
        android:id="@+id/rowRL"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/list_text"
            style="@style/UiTextView"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_alignParentBottom="true"
            android:background="#90FAEBD7"
            android:gravity="center"
            android:textSize="22sp" />

        <ImageView
            android:id="@+id/list_lock"
            android:layout_width="70dp"
            android:layout_height="wrap_content"
            android:layout_above="@+id/list_text"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_margin="5dp"
            android:src="@drawable/icon_lock_glow" />
    </RelativeLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/border" />
</FrameLayout>

SongsRepository(这就是我获取ID的方式):

public class Songs {

    public List<ISong> toList() {
        return Arrays.asList(
                new Song1(),
                new Song2(),
                new Song3(),
                new Song4(),
                new Song5(),
                new Song6(),
                new Song7(),
                new Song8(),
                new Song9(),
                new Song10(),
                new Song11(),
                new Song12(),
                new Song13(),
                new Song14(),
                new Song15(),
                new Song16(),
                new Song17(),
                new Song18(),
                new Song19(),
                new Song20());
    }

    public ISong getSong(int listPosition) {
        return toList().get(listPosition);
    }
}

和Song类的一个例子:

public class Song4 implements ISong {

    @Override
    public boolean isUnlocked() {
        return true;
    }

    @Override
    public int getNameId() {
        return R.string.song_4;
    }

    @Override
    public int getRawId() {
        return R.raw.song4;
    }

    @Override
    public int getIconId() {
        return R.drawable.box_song4;
    }

    @Override
    public int getBackgroundId() {
        return R.drawable.background_song4;
    }
}

0 个答案:

没有答案