私はアンドロイドアプリで相対レイアウトを使用しています。相対レイアウト下にある場合、プログレスバーは中央ではありません
以下は私のmain.xmlです。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="fill"
tools:context="com.example.asdf.MainActivity" >
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
android:src="@drawable/bgg" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="22dp"
android:layout_marginTop="22dp"
android:gravity="center"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:text=" Factualnote is an web annotation application, which helps the users to mark the specific text, element, page, video, etc in a web page and share it to like-minded people.\r\n \r\nAs we know the relevant data has been wide-spreaded across various sites under many intentions, factualnote is a type of social software tool in which factual data are brought forward or narrow down to the web users."
android:textColor="#ffffff"
android:textSize="25sp"
android:textStyle="normal|italic" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:orientation="vertical" >
<EditText
android:id="@+id/url"
android:layout_width="290dp"
android:layout_height="33dip"
android:layout_above="@+id/button_show"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:background="#ffffff"
android:ems="17"
android:hint="@string/edit_hint"
android:radius="10dp"
android:singleLine="true"
android:text="http://www.zeptoh.com/lynked/sel.html"
android:textColor="#000000"
android:textSize="16sp" >
<requestFocus />
</EditText>
<Button
android:id="@+id/button_show"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="@drawable/blue_button"
android:text="@string/button_title"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/undo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_weight="9"
android:background="@drawable/blue_button2"
android:text="@string/undo"
android:textColor="#ffffff" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_weight="9"
android:background="@drawable/blue_button2"
android:text="Mark"
android:textColor="#ffffff" />
<Button
android:id="@+id/done"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_weight="10"
android:background="@drawable/blue_button2"
android:text="Generate"
android:textColor="#ffffff" />
<Button
android:id="@+id/redo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_weight="9"
android:background="@drawable/blue_button2"
android:text="@string/redo"
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:id="@+id/rl2"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" >
<EditText
android:id="@+id/name"
android:layout_width="250dp"
android:layout_height="33dip"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#ffffff"
android:ems="17"
android:layout_gravity="center_horizontal"
android:hint="Enter Title"
android:singleLine="true"
android:textColor="#000000"
android:textSize="16sp" />
<EditText
android:id="@+id/desc"
android:layout_width="250dp"
android:layout_height="33dip"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:background="#ffffff"
android:ems="17"
android:layout_gravity="center_horizontal"
android:hint="Description about your note"
android:singleLine="true"
android:textColor="#000000"
android:textSize="16sp" />
<TextView
android:id="@+id/privateText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/desc"
android:layout_below="@+id/desc"
android:layout_marginTop="10dp"
android:text="Private Note:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff"
android:textSize="20sp"
android:checked="true"
android:buttonTint="@color/desing_color"
android:textStyle="bold" />
<RadioGroup
android:id="@+id/radioSex"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/privateText"
android:layout_toRightOf="@+id/privateText"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/yes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="1dp"
android:text="Yes"
android:buttonTint="@color/desing_color"
android:textColor="#ffffff"
android:textSize="15sp"
android:textStyle="bold" />
<RadioButton
android:id="@+id/no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/privateText"
android:layout_marginLeft="14dp"
android:layout_toRightOf="@+id/yes"
android:text="No"
android:textColor="#ffffff"
android:textSize="15sp"
android:checked="true"
android:buttonTint="@color/desing_color"
android:textStyle="bold" />
</RadioGroup>
<Button
android:id="@+id/generate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="@drawable/blue_button"
android:layout_below="@+id/radioSex"
android:layout_marginTop="10dp"
android:layout_marginLeft="70dp"
android:textColor="#ffffff"
android:text="Generate Note" />
<Button
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_below="@+id/radioSex"
android:background="@drawable/blue_button"
android:layout_marginTop="10dp"
android:layout_marginLeft="200dp"
android:textColor="#ffffff"
android:text="Back" />
</RelativeLayout>
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>
プログレスバーを水平と垂直の中央に配置しました。しかし、それは画面の上に置かれます。
リニアレイアウトrl2を削除すると、進行状況バーが中央に表示されます。
私はrl2を持っていても、センターで進行状況バーを取得する必要があります。そのが動作しない場合
あなたはアンドロイドを削除しようとしましたか?重力=メインのコンテナからの「塗りつぶし」ですか? (最初の相対レイアウト、すべてのレイアウトを含むレイアウト) – AndreiBogdan
スクリーンショットを添付すると便利です。 – Egor
私はあなたのコードを貼り付けてコピーし、正確に中央に来ています!! –