Android的图像视图重力重力、视图、图像、Android

2023-09-08 09:34:40 作者:诗酒趁年少

我如何动态设置的严重性?

  BMP位图;IM =新ImageView的(本);BMP = getbmp(IMG);im.setImageBitmap(BMP); 

现在我想将图像中的顶级。 main.xml中重力

:何可我这样做没有 Android的?

编辑:

main.xml中

 <?XML版本=1.0编码=UTF-8&GT?;<滚动型的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android    机器人:layout_width =FILL_PARENT机器人:layout_height =FILL_PARENT    机器人:滚动条=垂直    >< /滚动型> 

我有一个框架布局,我添加到它的图像,然后在文本,我想图像出现在屏幕的顶部。

 的FrameLayout FM =新的FrameLayout(本);fm.addView(IM);fm.addView(翅); //鳍=文本视图的setContentView(FM); 
Android图形绘制系统

解决方案

使用ImageView.setScaleType()与ImageView.ScaleType.FIT_START的价值。

How can I dynamically set the gravity ?

Bitmap bmp;
im = new ImageView (this);
bmp=getbmp(img);
im.setImageBitmap(bmp);  

Now I would like to put the image in the top . Ho can I do this without android:gravity in main.xml ?

EDIT :

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>

I have a frame layout and I add to it the image , and then the text and I would like the image to be on the top of the screen.

FrameLayout fm = new FrameLayout (this);
fm.addView(im);
fm.addView(fin); // fin = the text view
setContentView(fm);

解决方案

Use ImageView.setScaleType() with ImageView.ScaleType.FIT_START as value.