我知道这应该很简单,但android:scaleType="centerCrop"不会裁剪图像
我得到1950像素宽的图像,需要按父母的宽度裁剪.但android:scaleType="centerCrop"不会裁剪图像.我需要在布局中做什么才能显示前400个像素,例如或者任何屏幕/父宽度
抱歉,简单的问题 - 尝试谷歌 - 只有复杂的问题.而且我是新人,所以请不要请求.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rl1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background_color">
    <ImageView
            android:id="@+id/ver_bottompanelprayer"
            android:layout_width="match_parent"
            android:layout_height="227px"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:scaleType="matrix"
            android:background="@drawable/ver_bottom_panel_tiled_long" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
如果有唯一的方法是programmaticaly裁剪它 - 请给我一个方法的建议
我知道这应该很简单,但android:scaleType="centerCrop"不会裁剪图像
我得到1950像素宽的图像,需要按父母的宽度裁剪.但是android:scaleType="centerCrop"不要裁剪图像.我需要在布局中做什么才能显示前400个像素,例如或者任何屏幕/父宽度
对不起,简单的问题 - 尝试google它 - 只有复杂的问题.我是新人,所以不要downvote plz)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rl1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background_color">
    <ImageView
            android:id="@+id/ver_bottompanelprayer"
            android:layout_width="match_parent"
            android:layout_height="227px"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:scaleType="matrix"
            android:background="@drawable/ver_bottom_panel_tiled_long" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我正在为排球库做一些例子,其中有很少的文档/示例
public class MainActivity extends Activity {
    private ImageView mImageView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mImageView=(ImageView) findViewById(R.id.imageView1);
        RequestQueue queue = Volley.newRequestQueue(this); 
        ImageLoader imageLoader = new ImageLoader(queue,new BitmapLruCache());
        imageLoader.get("http://s017.radikal.ru/i413/1209/e7/648aa22cb947.jpg", ImageLoader.getImageListener(mImageView, R.drawable.ic_launcher, R.drawable.ic_launcher));
    }
Run Code Online (Sandbox Code Playgroud)
这会将URL从URL直接加载到ImageView中.但是,如果我想在将它放在ImageView上之前将其裁剪掉呢?
这个ImageLoader可以以某种方式将图像放置到位图吗?
是否有可能将res/raw中的html加载到TextView中?我知道我可以使用WebView,但该死的透明度并不总是有效(不是在每台设备上)
好吧,这一切折磨了我好几个星期,我将图像设置为 227 像素高,将其缩放到 170 像素,即使我希望它在任何时候都是 wrap_content。
好的。在这里,我采用了 1950 像素长的我的图像(我把它的一部分放在这里,这样你就可以理解它应该是什么样子)。

首先,我想将其缩放回 227 像素高,因为这就是它的设计方式以及应该如何
Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),R.drawable.ver_bottom_panel_tiled_long);
            int width = bitmapOrg.getWidth();
        int height = bitmapOrg.getHeight();
        int newWidth = 200; //this should be parent's whdth later
        int newHeight = 227;
        // calculate the scale
        float scaleWidth = ((float) newWidth) / width;
        float scaleHeight = ((float) newHeight) / height;
        // create a matrix for the manipulation
        Matrix matrix = new Matrix();
        // resize the bit map
        matrix.postScale(scaleWidth, scaleHeight);
        // recreate the new Bitmap …Run Code Online (Sandbox Code Playgroud)