android查看默认的填充或边距
似乎有些视图,如TextView,有自己的填充或边距…我的意思是,当我将textSize 16dp设置为TextView时,hdpi设备屏幕上显示此控件需要超过24个像素。也许我遗漏了什么,请帮忙android查看默认的填充或边距,android,view,Android,View,似乎有些视图,如TextView,有自己的填充或边距…我的意思是,当我将textSize 16dp设置为TextView时,hdpi设备屏幕上显示此控件需要超过24个像素。也许我遗漏了什么,请帮忙 <LinearLayout android:id="@+id/uc_button_title_panel" android:layout_width="wrap_content" android:layout_height="wrap_conten
<LinearLayout
android:id="@+id/uc_button_title_panel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/closed_red" />
<TextView
android:id="@+id/uc_button_title_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:includeFontPadding="false"
android:background="@null"
android:padding="0dp"
android:text="@string/demo_text"
android:textColor="#325083"
android:textSize="16dp"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/closed_red" />
</LinearLayout>
在android中,当使用布局时,默认的边距和可用的填充是:@dimen/activity\u vertical\u margin或@dimen/activity\u horizontal\u margin。我在上面放了一个示例代码 基于1.5倍的乘数,你是否期望它正好是24?是的。我想如果我想在hdpi设备上获得24px的文本大小,我必须将textSize设置为16dp还是不设置?是的,你是对的,我只是想理解两者之间的关系。那么你是说实际文本大于24px还是文本+周围的空间?文本和周围的空间有34像素高,你的布局是什么样子的?您的TextView很可能正在填充其父级。或者类似的东西。您可能需要发布实际布局(无论是xml还是java)。在阅读TextView源代码时,除了与字体相关的填充之外,我没有看到任何其他内容。这在本文中讨论过:您可能还想尝试手动将填充设置为0,以查看这是否会改变它。。。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:orientation="vertical">
</LinearLayout>