2017-02-20 60 views
0

我正在與Android的能量表的應用程序。我正在用mysql獲取數據。Android的相同位置的TextView

我想在一所房子的平面圖,顯示的數據,像這樣的:

Plan

我改變的TextView文本到我的數據。示例我正在展示一個10 kW的房間。 我的問題是我對相對佈局做了定位。當屏幕更改時。更大或更小。我的textview職位正在改變。它看起來非常糟糕。

我怎樣才能做到在圖像相同的位置。 謝謝。

+0

你能告訴我們一個截圖以及你想如何改變它嗎? –

回答

1

訣竅是找到你的計劃內的textViews的相對位置。像margin_left=80dp這樣的設置不會以響應的方式進行操作。

好消息!

現在已經可以用支持庫版本23使用android.support.percent.PercentRelativeLayoutandroid.support.percent.PercentFrameLayout設置一個百分比填充/保證金。

你必須弄清楚你的視圖在計劃中的百分比位置,你很好。

某些代碼

<android.support.percent.PercentRelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background:"@drawables/your_plan"> 

    <EditText 
     android:layout_height="wrap_content" 
     app:layout_widthPercent="13%" 
     app:layout_marginStartPercent="13%" 
     app:layout_marginEndPercent="13%" 
     android:text="Because 13 is my lucky number"/> 

</android.support.percent.PercentRelativeLayout> 

文檔

PercentFrameLayout.

PercentRelativeLayout.

PercentLayoutParams.

+0

感謝您的回覆。我怎麼能低於23我的設備是kitkat和果凍豆。 –

+0

這將很好地工作超過23 API較低水平,正如我所說的使用支持庫。 – AnixPasBesoin

+0

感謝您的回覆。我這樣做。我爲此工作了3天。今天我在1小時內完成。很感謝。 –