Я хочу создать custom title
для Dialog
:Возможно ли разместить компонент под другим внутри RelativeLayout?
public class MessageDialogView extends Builder {
private View view, titreView;
@SuppressLint("NewApi")
public MessageDialogView(Context context,LayoutInflater inflater) {
super(context);
view = inflater.inflate(R.layout.msg_dialog, null);
this.setView(view);
titreView = inflater.inflate(R.layout.custom_dialog_title, null);
this.setCustomTitle(titreView);
}
...
}
макета пользовательского заголовка:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
style="@style/ImpotsTitleStyle"
android:layout_marginBottom="0dp"
android:padding="0dp">
<ImageView
android:id="@+id/icone"
android:src="@drawable/ic_action_warning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/titre"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center_vertical"
style="@style/ImpotsStyleText"/>
</LinearLayout>
Во время выполнения текст заголовка не «по центру» в контексте всего всего заголовка, потому что есть значок слева от него!
Так что, если я поставил значок и текст заголовка в внутри RelativeLayout
, можно поместить TextView под значком? Если да, то какой атрибут xml подходит для этого?
Используйте 'FrameLayout' вместо' LinearLayout'. Дайте ImageView 'layout_gravity =" left "и TextView' 'layout_gravity =" center "' '. – Vikram