欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android 軟鍵盤(pán)的POPUP布局的問(wèn)題解決

 更新時(shí)間:2018年10月15日 09:56:21   作者:代碼日志  
這篇文章主要介紹了android 軟鍵盤(pán)的POPUP布局的問(wèn)題解決,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

我正在開(kāi)發(fā)一個(gè)軟鍵盤(pán),做得很好,但是我不知道如何自定義一個(gè)長(zhǎng)按鍵的彈出窗口.

我的鍵盤(pán)視圖:

<?xml version="1.0" encoding="UTF-8"?>
<android.inputmethodservice.KeyboardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:keyPreviewLayout="@layout/preview"
android:keyBackground="@drawable/key_selector"
android:shadowRadius="0.0"
android:keyTextColor="#000000"
/>

我的鍵盤(pán)布局:

<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="10%p"
android:keyHeight="10%p">

<Row android:verticalGap="1%p" android:horizontalGap="0.5%p" android:keyHeight="8%p" android:keyWidth="9.6%p">
 <Key android:codes="113" android:keyLabel="q" />
 <Key android:codes="119" android:keyLabel="w" />
 <Key android:codes="101" android:keyLabel="e" 
  />
 <Key android:codes="114" android:keyLabel="r" />
 <Key android:codes="116" android:keyLabel="t" />
 <Key android:codes="121" android:keyLabel="y"
   android:popupKeyboard="@xml/keyboard_popup" android:popupCharacters="yýÿ"/>
 <Key android:codes="117" android:keyLabel="u"
   android:popupKeyboard="@xml/keyboard_popup" android:popupCharacters="uúùũûü"/>
 <Key android:codes="105" android:keyLabel="i" 
   android:popupKeyboard="@xml/keyboard_popup" android:popupCharacters="iíìĩîï"/>
 <Key android:codes="111" android:keyLabel="o" 
   android:popupKeyboard="@xml/keyboard_popup" android:popupCharacters="oóò ôö" />
 <Key android:codes="112" android:keyLabel="p" />
</Row>
<Row android:verticalGap="1%p" android:horizontalGap="0.5%p" android:keyHeight="8%p" android:keyWidth="9.6%p">
 <Key android:codes="97" android:keyLabel="a" android:keyEdgeFlags="left" android:horizontalGap="5%p"
   android:popupKeyboard="@xml/keyboard_popup" android:popupCharacters="aáà âä"/>
 <Key android:codes="115" android:keyLabel="s" />
 <Key android:codes="100" android:keyLabel="d" />
 <Key android:codes="102" android:keyLabel="f" />
 <Key android:codes="103" android:keyLabel="g" />
 <Key android:codes="104" android:keyLabel="h" />
 <Key android:codes="106" android:keyLabel="j" />
 <Key android:codes="107" android:keyLabel="k" />
 <Key android:codes="108" android:keyLabel="l" />
</Row>
<Row android:verticalGap="1%p" android:horizontalGap="0.5%p" android:keyHeight="8%p" android:keyWidth="9.6%p">
 <Key android:codes="3"  android:keyIcon="@drawable/keyboard_shift_off" 
   android:keyHeight="7.6%p" android:keyWidth="13.7%p"/>
 <Key android:codes="122" android:keyLabel="z" android:horizontalGap="1%p"/>
 <Key android:codes="120" android:keyLabel="x" />
 <Key android:codes="99"  android:keyLabel="c"
   android:popupKeyboard="@xml/keyboard_popup" android:popupCharacters="cç"/>
 <Key android:codes="118" android:keyLabel="v" />
 <Key android:codes="98"  android:keyLabel="b" />
 <Key android:codes="110" android:keyLabel="n"
   android:popupKeyboard="@xml/keyboard_popup" android:popupCharacters="nñ"/>
 <Key android:codes="109" android:keyLabel="m" />
 <Key android:codes="-5"  android:keyIcon="@drawable/sym_keyboard_delete_dim"
  android:keyHeight="7.6%p" android:keyWidth="13.7%p" 
  android:horizontalGap="1%p"/>
</Row>
<Row android:verticalGap="1%p" android:horizontalGap="0.5%p" android:keyHeight="8%p" android:keyWidth="9.6%p">
 <Key android:codes="-16" android:keyIcon="@drawable/keyboard_symbol"
   android:keyHeight="7.6%p" android:keyWidth="18.7%p"/>
 <Key android:codes="44"  android:keyLabel="," android:horizontalGap="1%p"/>
 <Key android:codes="32"  android:keyIcon="@drawable/sym_keyboard_feedback_space" android:keyWidth="40%p"/>
 <Key android:codes="46"  android:keyLabel="."/>
 <Key android:codes="-3"  android:keyIcon="@drawable/keyboard_go" 
  android:keyHeight="7.6%p" android:keyWidth="18.5%p" android:horizontalGap="1%p"/>
</Row>

鍵盤(pán)彈出XML:

<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="10%p"
android:keyHeight="10%p">
</Keyboard>

我嘗試將keyBackground和背景屬性放在任何地方,但不成功.我試圖把:

android:popupLayout="@layout/keyboard"

…在keyboardView上得到nullpointer,也許我在該參數(shù)中輸入了錯(cuò)誤的XML?

在我放在這里的鍵盤(pán)彈出式XML中:

android:popupKeyboard="@xml/keyboard_popup"

我可以改變布局的大小,按鍵大小,鍵間距等等,但不能改變顏色或背景.

關(guān)鍵預(yù)覽也做得很好,我把它放在keyboardView上:

android:keyPreviewLayout="@layout/preview"

…它的工作原理我認(rèn)為彈出窗口應(yīng)該是一樣的,但不是這樣.

如何自定義出現(xiàn)長(zhǎng)按鍵的彈出式窗口?

那么這不是我正在尋找的,而是解決了這個(gè)問(wèn)題.

我自己創(chuàng)建了鍵盤(pán)視圖,并彈出一個(gè)彈出窗口來(lái)顯示一個(gè)鍵長(zhǎng)時(shí)間按下.

public class MyKeyboardView extends KeyboardView{
 @Override
 protected boolean onLongPress(final Key popupKey) {
  final View custom = LayoutInflater.from(context)
  .inflate(R.layout.popup_layout, new FrameLayout(context));
  popup = new PopupWindow(context);
  popup.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
  popup.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
  popup.showAtLocation(this, Gravity.NO_GRAVITY, popupKey.x, popupKey.y-50);
 }
}

這樣,您可以在xml中以任何方式自定義彈出窗口.

但是這不是正確的答案,如果你知道一個(gè)更好的方法來(lái)回答這個(gè)問(wèn)題.

http://stackoverflow.com/questions/34799775/soft-keyboards-popup-layout

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android架構(gòu)組件LiveData使用詳解

    Android架構(gòu)組件LiveData使用詳解

    這篇文章主要介紹了Android架構(gòu)組件LiveData使用詳解的相關(guān)資料,需要的朋友可以參考下
    2023-07-07
  • Android開(kāi)發(fā)實(shí)現(xiàn)自動(dòng)切換文字TextSwitcher功能示例

    Android開(kāi)發(fā)實(shí)現(xiàn)自動(dòng)切換文字TextSwitcher功能示例

    這篇文章主要介紹了Android開(kāi)發(fā)實(shí)現(xiàn)自動(dòng)切換文字TextSwitcher功能,結(jié)合實(shí)例形式詳細(xì)分析了Android使用TextSwitcher實(shí)現(xiàn)文字自動(dòng)切換的原理、實(shí)現(xiàn)方法及相關(guān)操作注意事項(xiàng),需要的朋友可以參考下
    2019-03-03
  • Android 8.0的緩存大小和緩存清理接口方法

    Android 8.0的緩存大小和緩存清理接口方法

    今天小編就為大家分享一篇Android 8.0的緩存大小和緩存清理接口方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-08-08
  • Android模擬器中窗口截圖存成文件實(shí)現(xiàn)思路及代碼

    Android模擬器中窗口截圖存成文件實(shí)現(xiàn)思路及代碼

    Android模擬器內(nèi)容是用OpenGL渲染的,所以用一般的編程截圖(如PrintWindow()等)會(huì)是黑屏。這是因?yàn)楫?huà)的東西放在framebuffer里 接下來(lái)介紹如何實(shí)現(xiàn)Android模擬器中窗口截圖存成文件,感興趣的朋友可以了解下哦
    2013-01-01
  • 實(shí)例講解Android應(yīng)用開(kāi)發(fā)中Fragment生命周期的控制

    實(shí)例講解Android應(yīng)用開(kāi)發(fā)中Fragment生命周期的控制

    這篇文章主要介紹了Android應(yīng)用開(kāi)發(fā)中Fragment生命周期的控制,Fragment依賴(lài)于Activity,所以生命周期方面也受Activity的影響,需要的朋友可以參考下
    2016-02-02
  • Android使用MMKV的記錄

    Android使用MMKV的記錄

    聽(tīng)說(shuō)騰訊的mmkv很牛皮,可以替代SharedPreferences,主要用來(lái)保存設(shè)置,比如串口號(hào)、波特率、攝像頭預(yù)覽角度等等,本文重點(diǎn)給大家介紹Android使用MMKV的記錄分享,感興趣的朋友一起看看吧
    2021-10-10
  • Android實(shí)現(xiàn)左滑退出Activity的完美封裝

    Android實(shí)現(xiàn)左滑退出Activity的完美封裝

    這篇文章主要介紹了Android實(shí)現(xiàn)左滑退出Activity的完美封裝,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • Android利用Document實(shí)現(xiàn)xml讀取和寫(xiě)入操作

    Android利用Document實(shí)現(xiàn)xml讀取和寫(xiě)入操作

    這篇文章主要為大家詳細(xì)介紹了Android利用Document實(shí)現(xiàn)xml讀取和寫(xiě)入操作,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-12-12
  • Flutter給控件實(shí)現(xiàn)鉆石般的微光特效

    Flutter給控件實(shí)現(xiàn)鉆石般的微光特效

    這篇文章主要給大家介紹了關(guān)于Flutter給控件實(shí)現(xiàn)鉆石般的微光特效的相關(guān)資料,實(shí)現(xiàn)的效果非常不錯(cuò),非常適合大家做開(kāi)發(fā)的時(shí)候參考,需要的朋友可以參考下
    2021-08-08
  • Android 8.1 Launcher3實(shí)現(xiàn)動(dòng)態(tài)指針時(shí)鐘功能

    Android 8.1 Launcher3實(shí)現(xiàn)動(dòng)態(tài)指針時(shí)鐘功能

    這篇文章主要介紹了Android 8.1 Launcher3實(shí)現(xiàn)動(dòng)態(tài)指針時(shí)鐘功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-07-07

最新評(píng)論