Android计量单位有什么区别?
user-interface android units-of-measurement dimension android-layout
如何创建以下视图.
1)使用listview或
2)在scrollview中膨胀自定义视图.这不仅是问题.
如果列表视图然后如何重叠行.
每行都有不同的颜色,来自api webservice.
在列表视图中,每行都有我在第二张图片中标记的红色部分的问题.甚至每行背景都不同,相同的颜色将出现在下面的行中.
如何在listview中做纹理效果?
I ran into a problem while coding in Kotlin. I copy-pasted a java code sample that converts DP to Pixels, in order to place it as a parameter for setting padding programatically. I was expecting the IDE to automatically transform it all to Kotlin, however it failed in the process.
The code in Java looks like the following:
float scale = getResources().getDisplayMetrics().density;
int dpAsPixels = (int) (sizeInDp*scale + 0.5f);
Run Code Online (Sandbox Code Playgroud)
After the translation to Kotlin:
val scale = resources.displayMetrics.density
val …
Run Code Online (Sandbox Code Playgroud) 我在MarshMallow
设备上进行了测试。当我写了XML EditText
和集PaddingBottom
来Retype EditText
。但它不起作用。但是,当我设置PaddingLeft
到New PassWord
EditText
工作正常。
xml代码:
<EditText
android:id="@+id/change_password_old_password_edittext"
android:layout_below="@+id/change_password_mobileNumber_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Old Password"
android:layout_marginTop="20.0dip"
android:textColorHint="#40000000"
android:textSize="@dimen/textsize16"/>
<EditText
android:id="@+id/change_password_new_password_edittext"
android:layout_below="@+id/change_password_old_password_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="New Password"
android:layout_marginTop="20.0dip"
android:textColorHint="#40000000"
android:paddingLeft="10dip"
android:textSize="@dimen/textsize16"/>
<EditText
android:id="@+id/change_password_retype_password_edittext"
android:layout_below="@+id/change_password_new_password_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Retype Password"
android:layout_marginTop="20.0dip"
android:paddingBottom="10dip"
android:textColorHint="#40000000"
android:textSize="@dimen/textsize16"/>
Run Code Online (Sandbox Code Playgroud)
屏幕截图:
然后,我决定以PaddingBottom
编程方式进行设置。但是它给出了奇怪的输出。
Java代码:
内部OnCreate
方法
EditText change_password_retype_password_edittext = (EditText)findViewById(R.id.change_password_retype_password_edittext);
change_password_retype_password_edittext.setPadding(0,0,0,10);
Run Code Online (Sandbox Code Playgroud)
输出:
注: 我已经测试上
Marshmallow
,LolliPop
也Jellybean
。但是在所有设备上都无法正常工作。