成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

Android是如何獲取點(diǎn)擊屏幕位置的坐標(biāo)的

本篇文章為大家展示了Android是如何獲取點(diǎn)擊屏幕位置的坐標(biāo)的,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。

成都網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)公司!專(zhuān)注于網(wǎng)頁(yè)設(shè)計(jì)、成都網(wǎng)站建設(shè)公司、微信開(kāi)發(fā)、微信小程序開(kāi)發(fā)、集團(tuán)成都企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。核心團(tuán)隊(duì)均擁有互聯(lián)網(wǎng)行業(yè)多年經(jīng)驗(yàn),服務(wù)眾多知名企業(yè)客戶(hù);涵蓋的客戶(hù)類(lèi)型包括:成都生料攪拌車(chē)等眾多領(lǐng)域,積累了大量豐富的經(jīng)驗(yàn),同時(shí)也獲得了客戶(hù)的一致稱(chēng)揚(yáng)!

布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context="com.example.com.TouchTest" >

  <LinearLayout
    android:id="@+id/ll_touch"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
      android:id="@+id/touch_show_start"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/hello_world" />

    <TextView
      android:id="@+id/touch_show"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/hello_world" />
  </LinearLayout>

</RelativeLayout>

Activity中的操作:

public class TouchTest extends Activity implements OnTouchListener {

  private TextView tvTouchShowStart;
  private TextView tvTouchShow;
  private LinearLayout llTouch;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_touch_test);
    init();
  }

  private void init() {
    tvTouchShowStart = (TextView) findViewById(R.id.touch_show_start);
    tvTouchShow = (TextView) findViewById(R.id.touch_show);
    llTouch = (LinearLayout) findViewById(R.id.ll_touch);
    llTouch.setOnTouchListener(this);
  }

  @Override
  public boolean onTouch(View v, MotionEvent event) {
    switch (event.getAction()) {
    /**
    * 點(diǎn)擊的開(kāi)始位置
    */
    case MotionEvent.ACTION_DOWN:
      tvTouchShowStart.setText("起始位置:(" + event.getX() + "," + event.getY());
      break;
    /**
    * 觸屏實(shí)時(shí)位置
    */
    case MotionEvent.ACTION_MOVE:
      tvTouchShow.setText("實(shí)時(shí)位置:(" + event.getX() + "," + event.getY());
      break;
    /**
    * 離開(kāi)屏幕的位置
    */
    case MotionEvent.ACTION_UP:
      tvTouchShow.setText("結(jié)束位置:(" + event.getX() + "," + event.getY());
      break;
    default:
      break;
    }
    /**
    * 注意返回值
    * true:view繼續(xù)響應(yīng)Touch操作;
    * false:view不再響應(yīng)Touch操作,故此處若為false,只能顯示起始位置,不能顯示實(shí)時(shí)位置和結(jié)束位置
    */
    return true;
  }

}

上述內(nèi)容就是Android是如何獲取點(diǎn)擊屏幕位置的坐標(biāo)的,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

文章標(biāo)題:Android是如何獲取點(diǎn)擊屏幕位置的坐標(biāo)的
文章地址:http://jinyejixie.com/article6/ijjoog.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站、ChatGPT網(wǎng)站營(yíng)銷(xiāo)、商城網(wǎng)站、電子商務(wù)、全網(wǎng)營(yíng)銷(xiāo)推廣

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)
南安市| 小金县| 云安县| 金山区| 布拖县| 江安县| 天等县| 武冈市| 开化县| 通州区| 红原县| 龙门县| 鹤岗市| 绥江县| 汤阴县| 庄河市| 昂仁县| 玉环县| 旬邑县| 寿阳县| 平昌县| 保定市| 丹寨县| 米林县| 游戏| 清流县| 五家渠市| 婺源县| 宁化县| 常德市| 襄樊市| 鲁山县| 天门市| 辰溪县| 祁阳县| 湛江市| 顺昌县| 漯河市| 友谊县| 墨江| 贡觉县|