我在使用ICS的模拟器上遇到了一个奇怪的问题(但在API级别为21的模拟器上却没有)。我创建了一个自定义键盘:
现在每当我点击一个键时,键盘的宽度会自动增加一点点。几次敲击键后,它的外观如下:
在logcat上我看到" GC_FOR_ALLOC已释放"每次我按一下钥匙。我不明白导致宽度增加的原因。
xml:
$str='[\n {\n "short_link" : "http:\/\/website.com\/img1085805",
\n "id" : "ca96c55e1aa76fbca17ee08cad7e5a15",
\n "thumb" : "http:\/\/images.website.com\/boxdata\/asset22114\/images\/thumb__chat_files_41.jpg?r=160421015318",
\n "type" : "img",\n "path" : "http:\/\/images.website.com\/boxdata\/asset22114\/images\/chat_files_41.jpg?r=160421015318",
\n "name" : "chat_files_41.jpg",\n "mime_type" : "image\/jpg"\n }\n]';
echo stripslashes(str_replace('\n','',$str));
键盘xml:
<?xml version="1.0" encoding="utf-8"?>
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".SignInScreen">
<ImageView
android:layout_width="@dimen/companyImageWidth"
android:layout_height="wrap_content"
android:id="@+id/companyLogo"/>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/marginUserListHor"
android:layout_marginRight="@dimen/marginUserListHor"
android:layout_marginTop="@dimen/marginUserListVer"
android:layout_marginBottom="@dimen/marginUserListVer"
android:layout_centerVertical="true"
android:id="@+id/scrollView">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:id="@+id/usersList_signIn"/>
</ScrollView>
<com.ruach.pos.restaurant.MyKeyboardView
android:id="@+id/passwordKeyboard"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/scrollView"
android:layout_centerVertical="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:visibility="visible"
android:padding="4dp"
android:keyBackground="@drawable/keyboard_key_btn"
android:keyTextColor="@color/black"
android:shadowColor="@color/transparent"
android:keyTextSize="@dimen/textSizeMed"
android:labelTextSize="@dimen/textSizeMed"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberPassword"
android:id="@+id/userPasswordSignIn"
android:layout_alignLeft="@+id/passwordKeyboard"
android:layout_alignRight="@+id/passwordKeyboard"
android:layout_marginBottom="@dimen/marginPasswordField"
android:layout_marginRight="@dimen/marginPasswordField"
android:layout_above="@+id/passwordKeyboard"
android:textSize="@dimen/textSizeMed"
android:background="@drawable/white_black_stroke_rect"
android:paddingLeft="@dimen/usrPassPaddingLeft"/>
</RelativeLayout>