2012-02-08 26 views
0

私はウィジェットを作成しました。ネットワーク名、IPアドレス、MACアドレスなど、WiFiの詳細を表示します。 しかし、私はウィジェットで使用しているテキストの固定サイズを与えることができません。画面が変わる場合は、テキストサイズも調整する必要があります。私たちはそれをどうやってできるのですか?別の携帯電話のAndroidウィジェット

My 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> 
+0

いくつかのコードを追加し、あなたが試したかを示します。 – nhaarman

+0

が私のレイアウトを追加しました – Kamalone

+0

固定サイズを参照する場合、フォントサイズまたはウィジェットで利用可能なスペースを意味しますか? –

答えて

1

あなたはTextSizeためspを使用する必要があります。

<TextView 
    android:id="@+id/wifi_status" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textSize="12sp" 
/> 

Read more.