我知道我们可以为android:gravity和 android:layout_gravity属性设置以下值:
centercenter_verticalcenter_horizontal等但我对这两个问题感到困惑.
使用android:gravity和有android:layout_gravity什么区别?
我不明白如何使用这个属性.谁能告诉我更多关于它的事情?
我想创建选项卡式应用程序.一切都很好,但是当我创建标签时.标签之间的空间太大了.我想删除这个填充或边距,但我不知道我该怎么做.有什么建议吗?
XML
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none" >
<TabWidget
android:id="@android:id/tabs"
android:padding="0px"
android:layout_margin="0px"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:tag="tab0"
android:text="Tab 1"
android:padding="0px"
android:layout_margin="0px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:tag="tab1"
android:text="Tab 2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:tag="tab2"
android:text="Tab 3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:tag="tab3"
android:text="Tab 4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:tag="tab4"
android:text="Tab 5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:tag="tab5"
android:text="Tab 6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:tag="tab6"
android:text="Tab 7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:tag="tab7"
android:text="Tab …Run Code Online (Sandbox Code Playgroud) <TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="10"
android:layout_alignBottom="@+id/editText2"
android:layout_alignRight="@+id/editText2"
android:layout_alignEnd="@+id/editText2"
android:layout_marginBottom="63dp"
android:text="@string/hello" />
Run Code Online (Sandbox Code Playgroud)
每当我输入没有字符串的文本时,它会给我一个黄色的符号.所以我做了一个字符串.现在我在layout_height上得到了上面的消息.我是android开发的新手.
我imageview在 android 中imageview使用,当我将图像放入使用wrap_content高度和宽度的属性时。图像看起来像实际大小一样大,或者如果我拍摄小图像,它们会变得模糊。
为它编码
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/showhide"
android:layout_marginRight="20sp"
android:layout_marginLeft="20sp"
android:layout_marginTop="10sp"
android:padding="5sp"
android:weightSum="4"
>
<!-- delivery intimation-->
<LinearLayout android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/layout_d_i"
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_weight="1"
android:weightSum="2"
>
<ImageView android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.5"
android:src="@drawable/delivintimation"
android:id="@+id/delivery_intimation"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:layout_marginBottom="10sp"
/>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Delivery Intimation"
android:gravity="center"
android:maxLines="100"
android:singleLine="false"
android:layout_below="@id/delivery_intimation"
android:textSize="12sp"
android:textColor="@android:color/black"
/>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)