相关疑难解决方法(0)

Android:居中图片

我有线性布局和图像......

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">

<ImageView android:layout_width="wrap_content" android:id="@+id/imageView1"
 android:src="@drawable/icon" android:layout_height="wrap_content"
 android:scaleType="center"></ImageView>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

如何动态居中我的图像,使其显示在所有设备的屏幕中央?

android android-layout

44
推荐指数
3
解决办法
12万
查看次数

Android图像视图重力

如何动态设置重力?

Bitmap bmp;
im = new ImageView (this);
bmp=getbmp(img);
im.setImageBitmap(bmp);  
Run Code Online (Sandbox Code Playgroud)

现在我想将图像放在顶部.我可以android:gravity在main.xml中执行此操作吗?

编辑:

main.xml中

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:scrollbars="vertical"

    >
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

我有一个框架布局,我添加了图像,然后文本,我希望图像在屏幕的顶部.

FrameLayout fm = new FrameLayout (this);
fm.addView(im);
fm.addView(fin); // fin = the text view
setContentView(fm);
Run Code Online (Sandbox Code Playgroud)

android image view gravity

12
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×2

android-layout ×1

gravity ×1

image ×1

view ×1