2016年5月26日 星期四

Recyclerview inside ScrollView not scrolling smoothly

Method 1:

Reference:

http://stackoverflow.com/questions/33143485/recyclerview-inside-scrollview-not-scrolling-smoothly

Illustration:

RecyclerView view = (RecyclerView) findViewById(R.id.myrecycler);
view .setNestedScrollingEnabled(false);

Drawback:

OutOfMemory when there are many bitmap in the RecyclerView


Method 2:

Wrap all the component into the RecyclerView

Error: ArrayAdapter requires the resource ID to be a TextView

Reference:

http://stackoverflow.com/questions/9280965/arrayadapter-requires-the-resource-id-to-be-a-textview-xml-problems

Illustration:

Layout xml裡只能包含一個 TextView,不能將 TextView包在其他的 layout裡,例如:LinearLayou

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ......
/>

2016年5月6日 星期五

String Resources: Formatting and Styling

References:

http://developer.android.com/intl/zh-tw/guide/topics/resources/string-resource.html#FormattingAndStyling


Example:

<string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>

Resources res = getResources();
String text = String.format(res.getString(R.string.welcome_messages), username, mailCount);

TextView 省略文字的用法

Reference:

http://blog.csdn.net/sonicliji/article/details/8523746

illustration:

1.android:ellipsize=”start”—–省略號顯示在開頭
Ex: ......start
2.android:ellipsize=”end”——省略號顯示在結尾
Ex: end.......
3.android:ellipsize=”middle”—-省略號顯示在中間
4.android:ellipsize=”marquee”–以跑馬燈的方式顯示(動畫橫向移動)