0
Android小工具我创建了一个小部件。它显示了WiFi的详细信息,如网络名称,IP和MAC地址。 但我不能给出一个固定大小的,我现在用的插件的文本。如果屏幕改变文字大小,也需要随之调整。我们如何做到这一点?在不同的手机
我的XML文件如下。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/widget_margin" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="@+id/wifi_background"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/padding_left"
android:paddingTop="22dp"
android:orientation="vertical"
>
<FrameLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/wifi_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12dp"
/>
<TextView
android:id="@+id/wifi_on"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="12dp"
/>
</FrameLayout>
<TextView
android:id="@+id/wifi_notconnected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="7dp"
/>
</LinearLayout>
<ImageView
android:id="@+id/wifi_signal_strength"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/wifi_circle"
android:layout_width="@dimen/circle_width"
android:layout_height="@dimen/circle_hieght"
android:layout_marginLeft="2dp"
android:layout_gravity="center_vertical"
android:background="@drawable/onpress_wifi_icon_circle_null"
android:src="@drawable/toggle" />
<ImageView
android:id="@+id/wifi_square"
android:layout_width="@dimen/square_width"
android:layout_height="@dimen/square_hieght"
android:layout_marginTop="8dp"
android:layout_gravity="right|top"
android:background="@drawable/onpress_network_info_squre_null"
android:src="@drawable/togglenetwork" />
</FrameLayout>
添加一些代码,并显示你试过什么。 – nhaarman 2012-02-08 11:12:45
添加了我的布局 – Kamalone 2012-02-08 11:15:07
当您引用固定大小时,是指字体大小还是小部件中可用的空间? – 2012-02-08 11:21:48