Obsolete
Status Update
Comments
ig...@udachi.net <ig...@udachi.net> #2
Also, by using layout.getLineBottom(), the last line of the layout seems also to be with a wrong height.
Maybe the first and the last lines are different from the other lines by design? If so, where can I see the documentation about this?
Maybe the first and the last lines are different from the other lines by design? If so, where can I see the documentation about this?
ro...@android.com <ro...@android.com>
ro...@google.com <ro...@google.com>
cl...@google.com <cl...@google.com>
si...@google.com <si...@google.com>
sa...@google.com <sa...@google.com> #3
Thank you for your feedback. We have tried our best to address the issue reported, however our product team has shifted work priority which doesn't include this issue. For now, we will be closing the issue as "Won't Fix (Obsolete)". If this issue still currently exists, we request that you log a new issue along with the latest bug report here: https://goo.gl/TbMiIO and reference this bug for context.
Description
Code to reproduce:
<RelativeLayout xmlns:android="
xmlns: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=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Line 0\nLine 1\nLine 2\nLine 3\nLine 4"
android:textSize="10sp" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignParentBottom="true"
android:onClick="onBtnClick"
android:text="Button" />
</RelativeLayout>
public class MainActivity extends Activity {
Layout layout;
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv = (TextView) findViewById(R.id.textView1);
}
public void onBtnClick(View view) {
float density = getResources().getDisplayMetrics().density;
layout = tv.getLayout();
int line_top = 0;
int previous_line = 0;
for (int i = 0; i < layout.getLineCount(); i++) {
line_top = layout.getLineTop(i);
Log.d("bug", "Text Size: "
+ (int) (tv.getTextSize() / density + 0.5f)
+ " line_top: " + line_top + " curr - prev: "
+ (line_top - previous_line));
previous_line = line_top;
}
}
}
Set 'bug' as Log filter..
Nexus7 emulator,
TextView text size 10sp:
Text Size: 10 line_top: 0 curr - prev: 0
Text Size: 10 line_top: 17 curr - prev: 17
Text Size: 10 line_top: 32 curr - prev: 15
Text Size: 10 line_top: 47 curr - prev: 15
Text Size: 10 line_top: 62 curr - prev: 15
*** The first's line height is 17, the rest lines are 15
*** 17 - 15 = 2 => 0.2 of the text size.
TextView text size 20sp:
Text Size: 20 line_top: 0 curr - prev: 0
Text Size: 20 line_top: 36 curr - prev: 36
Text Size: 20 line_top: 68 curr - prev: 32
Text Size: 20 line_top: 100 curr - prev: 32
Text Size: 20 line_top: 132 curr - prev: 32
*** Same with text size 20.. 36 - 32 = 4 => 0.2 of the text size.
TextView text size 30sp:
Text Size: 30 line_top: 0 curr - prev: 0
Text Size: 30 line_top: 53 curr - prev: 53
Text Size: 30 line_top: 100 curr - prev: 47
Text Size: 30 line_top: 147 curr - prev: 47
Text Size: 30 line_top: 194 curr - prev: 47
*** Same with text size 30.. 53 - 47 = 6 => 0.2 of the text size.
Also done with Nexus S emulator and SG4 real device. Same 0.2 scale error.