ネットワークから画像をダウンロードし、scaleType = "centerInside"オプションを使用してGlideでImageViewに表示しようとしています。Androidでグライドが小さすぎるネットワークからの画像
何らかの理由で、画像がネットワークからダウンロードされたときに、同じ画像がリソースからImageViewに入れられたときよりも、画面上でははるかに小さく見えます。
例:
両方の画像がhereを見出すことができます。リソースから設定された画像でさえ、私のラップトップに表示されているものと比べて、実際には小さく見えると主張します。再生中の画面の密度に関連するものがあることを理解していますが、これらの画像を「ユーザーフレンドリーなサイズ」、たとえば少し大きくするにはどうすればよいですか?
600x250ピクセルサイズのdifferent imageでも、電話では(画像ビューのlayout_heightとlayout_widthが "wrap_content"に設定されていて)ちょっとです。
活動からのコード:
public class DisplayImagesActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.display_image_activity);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
setTitle("Hello StackOverflow!");
ImageView top_left = (ImageView) findViewById(R.id.top_left);
ImageView top_right = (ImageView) findViewById(R.id.top_right);
ImageView bottom_left = (ImageView) findViewById(R.id.bottom_left);
ImageView bottom_right = (ImageView) findViewById(R.id.bottom_right);
String[] urls = new String[] {
"http://imgur.com/6jMOdg0.png",
"http://imgur.com/AhIziYr.png"
};
top_left.setImageResource(R.drawable.top_left);
top_right.setImageResource(R.drawable.top_right);
Glide.with(this)
.load(urls[0])
.signature(new StringSignature(new Date().toString()))
.into(bottom_left);
Glide.with(this)
.load(urls[1])
.signature(new StringSignature(new Date().toString()))
.into(bottom_right);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
this.finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
display_image_activity.xmlファイル:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/match_parent"
android:orientation="vertical">
<include layout="@layout/_toolbar" />
<ScrollView
style="@style/match_parent">
<RelativeLayout
style="@style/match_parent"
android:padding="16dp">
<TextView
style="@style/wrap_content"
android:id="@+id/text_resources"
android:layout_marginBottom="10dp"
android:text="From Resources"/>
<ImageView
android:id="@+id/top_left"
android:background="@color/Linen"
android:layout_width="150dp"
android:layout_height="120dp"
android:layout_marginBottom="20dp"
android:layout_below="@id/text_resources"
android:scaleType="centerInside"/>
<ImageView
android:id="@+id/top_right"
android:background="@color/Linen"
android:layout_width="150dp"
android:layout_height="120dp"
android:layout_toRightOf="@id/top_left"
android:layout_toEndOf="@id/top_left"
android:layout_below="@id/text_resources"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:scaleType="centerInside"/>
<TextView
style="@style/wrap_content"
android:id="@+id/text_network"
android:layout_below="@id/top_left"
android:layout_marginBottom="10dp"
android:text="From Network"/>
<ImageView
android:id="@+id/bottom_left"
android:background="@color/Linen"
android:layout_width="150dp"
android:layout_height="120dp"
android:layout_below="@id/text_network"
android:scaleType="centerInside" />
<ImageView
android:id="@+id/bottom_right"
android:background="@color/Linen"
android:layout_width="150dp"
android:layout_height="120dp"
android:layout_toRightOf="@id/bottom_left"
android:layout_toEndOf="@id/bottom_left"
android:layout_below="@id/text_network"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:scaleType="centerInside" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
ありがとうございました。
はあなたの提案は何も変わりませんが、それはいけません。私が定義したサイズは、ImageViewsをどれくらい大きくしたいのかということです(ImageViewsのための画像の背景が異なります)。しかし、内部の画像は大きくなるはずです。 –