2017-02-26 17 views
0

私はちょうどウィジェットを起動し、そのxmlはAS上のエミュレータでイメージビューを表示しますが、イメージビューをどの位置に置いてもイメージビューは表示されません。ここでウィジェットAndroid Widget ImageViewが表示されない

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#333" 
android:padding="@dimen/widget_margin"> 

<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    app:srcCompat="@android:drawable/ic_popup_sync" 
    android:id="@+id/imageView" 
    android:layout_alignParentLeft="true"/> 

<LinearLayout 
    android:orientation="horizontal" 
    android:layout_alignLeft="@+id/imageView" 
    android:layout_alignRight="@+id/imageView2" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:weightSum="10"> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="4"> 

     <TextView 
      android:text="TextView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/textView2" /> 

     <TextView 
      android:text="TextView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/textView3" /> 

     <TextView 
      android:text="TextView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/textView4" /> 
    </LinearLayout> 

    <TextView 
     android:text="16:00" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:id="@+id/textView5" 
     android:textSize="20sp" 
     android:layout_weight="3" /> 

    <TextView 
     android:text="14:00" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:textSize="12sp" 
     android:id="@+id/textView6" 
     android:layout_weight="1" /> 

</LinearLayout> 

<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    app:srcCompat="@android:drawable/ic_media_next" 
    android:id="@+id/imageView2" /> 
</RelativeLayout> 

emulator

on test phone

の私のxmlレイアウトであっても、私はハードコードさdpまたは他のオプションとのLinearLayoutまたはrelativelayoutの内側に入れても、内部でOKです他のプロジェクトの画像を変更しますアプリ、何も示していない。私はそれがなぜ表示されないのか不思議です。

答えて

0

LinearLayoutは、ImageViewの上に描画されるため、表示されません。代わりに、アプリのSRC:srcCompatアンドロイドを使用してみてくださいLinearLayout

ImageView以下
<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    app:srcCompat="@android:drawable/ic_popup_sync" 
    android:id="@+id/imageView" 
    android:layout_alignParentLeft="true"/> 

<LinearLayout 
    android:layout_below="@+id/imageView" //add this to set this layout below imageview 
    android:orientation="horizontal" 
    android:layout_alignLeft="@+id/imageView" 
    android:layout_alignRight="@+id/imageView2" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:weightSum="10"> 
+0

ご返信いただきまして申し訳ございませんが、この方法を試しましたが、まだ何も表示されていません。 – CbL

0

を設定する

してみてください。私はそれが最良の解決策であるかどうかわかりませんが、それは私のために働きます。

<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@android:drawable/ic_popup_sync" 
    android:id="@+id/imageView" 
    android:layout_alignParentLeft="true"/> 
+0

返信用のThx。 srcですべての画像ビューを変更しようとしましたが、ウィジェットではまだ動作しません。私はこれが活動の仕事だとわかるが、ウィジェットに変更すると、まだ空白になっている – CbL

0

もう1つのオプションが見つかりました。 'src'を設定する代わりに、Drawableを表示するようにImageViewの背景を設定することができます。再び、まだまだ良い解決策ではありませんが、引き出しが目に見えます。

<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@android:drawable/ic_popup_sync" 
    android:id="@+id/imageView" 
    android:layout_alignParentLeft="true"/> 
関連する問題