Android SDK 18 TextView重力无法垂直工作
我对SDK 18有疑问.我的文本视图的重力在垂直方向上不起作用.但是它正在使用sdk17.
I have a probleme with the SDK 18. The gravity of my text view doesn't work vertically. But it's working with sdk17.
图片和代码:
header_of_listView.xml:
header_of_listView.xml :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/iv_bg"
android:layout_width="wrap_content"
android:layout_height="@dimen/entete.size.h"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:contentDescription="@string/blank"
android:scaleType="fitXY"
android:src="@drawable/cellule_flecher_mise_en_valeur" />
<TextView
android:id="@+id/tv_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/iv_bg"
android:layout_alignLeft="@id/iv_bg"
android:layout_alignRight="@id/iv_bg"
android:layout_alignTop="@id/iv_bg"
android:layout_marginBottom="6dp"
android:gravity="center"
android:text="@string/a_remplacer"
android:textColor="@color/tableviewText"
android:textSize="18sp"
android:textStyle="bold"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
AndroidManifest.xml
AndroidManifest.xml
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
AndroidManifest.xml
AndroidManifest.xml
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
具有黑色背景的textviewandroid:background =#000000"
with black background for textview android:background="#000000"
如果有人有想法.我尝试用match_parent更改wrap_content.
If someone have an idea. I have try to change wrap_content with match_parent.
唯一起作用的是android:layout_height ="@ dimen/entete.size.h"在TextView上,但余量不适用.目前,我将项目留在SDK 17中.
The only thing that work is android:layout_height="@dimen/entete.size.h" on the TextView, but the margin doesn't apply. For the moment I leave the project to SDK 17.
问题是RelativLayout作为listview项的根布局.如果将LinearLayout放在RelativeLayout周围,则也可以在targetSdk = 19的情况下使用.GridView出现相同的问题.
The problem is the RelativLayout as root layout of the listview item. If your put a LinearLayout around the RelativeLayout it works also with targetSdk = 19. Same problem appears with the GridView.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
... your layout like before
</LinearLayout>
这并不是一个很好的解决方法-但比我认为targetSdk = 17更好.
This is not really a nice workaround - but better than put targetSdk = 17 I guess.