Android 開發筆記___映像視圖

來源:互聯網
上載者:User

標籤:rri   drawable   image   example   utf-8   oid   static   pat   this   

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical">    <ImageView        android:id="@+id/iv_scale"        android:layout_width="match_parent"        android:layout_height="300dp"        android:layout_marginTop="10dp"        android:src="@drawable/apple1" />    <LinearLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_marginTop="10dp"        android:orientation="horizontal">        <Button            android:id="@+id/btn_fitCenter"            android:layout_width="0dp"            android:layout_height="wrap_content"            android:layout_weight="1"            android:text="fitCenter"            android:textColor="#000000"            android:textSize="11sp" />        <Button            android:id="@+id/btn_centerCrop"            android:layout_width="0dp"            android:layout_height="wrap_content"            android:layout_weight="1"            android:text="centerCrop"            android:textColor="#000000"            android:textSize="11sp" />        <Button            android:id="@+id/btn_centerInside"            android:layout_width="0dp"            android:layout_height="wrap_content"            android:layout_weight="1"            android:text="centerInside"            android:textColor="#000000"            android:textSize="11sp" />    </LinearLayout>    <LinearLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_marginTop="10dp"        android:orientation="horizontal">        <Button            android:id="@+id/btn_center"            android:layout_width="0dp"            android:layout_height="wrap_content"            android:layout_weight="1"            android:text="center"            android:textColor="#000000"            android:textSize="11sp" />        <Button            android:id="@+id/btn_fitXY"            android:layout_width="0dp"            android:layout_height="wrap_content"            android:layout_weight="1"            android:text="fitXY"            android:textColor="#000000"            android:textSize="11sp" />        <Button            android:id="@+id/btn_fitStart"            android:layout_width="0dp"            android:layout_height="wrap_content"            android:layout_weight="1"            android:text="fitStart"            android:textColor="#000000"            android:textSize="11sp" />        <Button            android:id="@+id/btn_fitEnd"            android:layout_width="0dp"            android:layout_height="wrap_content"            android:layout_weight="1"            android:text="fitEnd"            android:textColor="#000000"            android:textSize="11sp" />    </LinearLayout>    <Button        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text="截屏"        android:id="@+id/btn_2.3.3.2"/></LinearLayout>

  Java

package com.example.alimjan.hello_world;import android.content.Context;import android.content.Intent;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.widget.Button;import android.widget.ImageView;/** * Created by alimjan on 6/30/2017. */public class class__2_3_3 extends AppCompatActivity implements View.OnClickListener {    private ImageView iv_scale;    private Button btn_2_3_3_2;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.code_2_3_3);        iv_scale = (ImageView) findViewById(R.id.iv_scale);        findViewById(R.id.btn_center).setOnClickListener(this);        findViewById(R.id.btn_fitCenter).setOnClickListener(this);        findViewById(R.id.btn_centerCrop).setOnClickListener(this);        findViewById(R.id.btn_centerInside).setOnClickListener(this);        findViewById(R.id.btn_fitXY).setOnClickListener(this);        findViewById(R.id.btn_fitStart).setOnClickListener(this);        findViewById(R.id.btn_fitEnd).setOnClickListener(this);        btn_2_3_3_2 = (Button) findViewById(R.id.btn_2_3_3_2);        btn_2_3_3_2.setOnClickListener(this);    }    @Override    public void onClick(View v) {        if (v.getId() == R.id.btn_center) {            iv_scale.setScaleType(ImageView.ScaleType.CENTER);        } else if (v.getId() == R.id.btn_fitCenter) {            iv_scale.setScaleType(ImageView.ScaleType.FIT_CENTER);        } else if (v.getId() == R.id.btn_centerCrop) {            iv_scale.setScaleType(ImageView.ScaleType.CENTER_CROP);        } else if (v.getId() == R.id.btn_centerInside) {            iv_scale.setScaleType(ImageView.ScaleType.CENTER_INSIDE);        } else if (v.getId() == R.id.btn_fitXY) {            iv_scale.setScaleType(ImageView.ScaleType.FIT_XY);        } else if (v.getId() == R.id.btn_fitStart) {            iv_scale.setScaleType(ImageView.ScaleType.FIT_START);        } else if (v.getId() == R.id.btn_fitEnd) {            iv_scale.setScaleType(ImageView.ScaleType.FIT_END);        } else if (v.getId() == R.id.btn_2_3_3_2){            class__2_3_3_2.startHome(class__2_3_3.this);        }    }    public static void startHome(Context mContext) {        Intent intent = new Intent(mContext, class__2_3_3.class);        mContext.startActivity(intent);    }}

 

Android 開發筆記___映像視圖

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.