Android 当我在手机上调试时,Eclipse会显示不同的结果
这是eclipse在编辑器中显示的内容 这就是我在手机上运行它时的样子 这是我使用的代码Android 当我在手机上调试时,Eclipse会显示不同的结果,android,xml,eclipse,debugging,sdk,Android,Xml,Eclipse,Debugging,Sdk,这是eclipse在编辑器中显示的内容 这就是我在手机上运行它时的样子 这是我使用的代码 <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="bottom" > <Button android:id="@+id/buttonLocation" andro
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom" >
<Button
android:id="@+id/buttonLocation"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/settings_button"
android:text="Settings" android:textStyle="bold" android:textSize="24dp" android:textColor="#000000" android:gravity="center_horizontal"/>
</LinearLayout>
我需要设置在中心。如何解决此问题 试试这个
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom" >
<Button
android:id="@+id/buttonLocation"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/settings_button"
android:gravity="center"
android:text="Settings" android:textStyle="bold" android:textSize="24dp" android:textColor="#000000" android:gravity="center_horizontal"/>
</LinearLayout>
android:layout\u重力用于设置视图或布局相对于其父视图的重力 对于按钮元素,添加
android:layout\u gravity=“center”
这应该使它居中
另外,不确定,但可能由于选择的文本大小,您会得到不同的结果…请尝试较小/较大的大小,并检查结果是否不同。我添加了android:layout\u gravity=“center”并更改了字体,但它仍然没有在我的手机上居中。好的,抱歉。在你的线性布局中,而不是android:gravity=“bottom”将其设置为
中心
我尝试过,但“设置”文本仍然不在中心。我还使用了android:gravity=“bottom”,因为我希望底部位于屏幕底部。文字在图形布局中居中,但当我在手机上运行时,文字在左侧。这没有任何意义。张贴您的整个布局。