-1
A
回答
0
您可以在這裏找到一個解決方案:
https://stackoverflow.com/a/25143739/5907003
如果你想calculate the height dynamically您可以使用下面的代碼:
int finalHeight, finalWidth;
final ImageView iv = (ImageView)findViewById(R.id.scaled_image);
final TextView tv = (TextView)findViewById(R.id.size_label);
ViewTreeObserver vto = iv.getViewTreeObserver();
vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
public boolean onPreDraw() {
iv.getViewTreeObserver().removeOnPreDrawListener(this);
finalHeight = iv.getMeasuredHeight();
finalWidth = iv.getMeasuredWidth();
tv.setText("Height: " + finalHeight + " Width: " + finalWidth);
return true;
}
});
還只是一個想法,如果可以幫助,你可以將圖像分成兩部分,並將它們與您的佈局對齊,以對齊底部並將頂部對齊相應的佈局
對於圓角背景,您可以在可繪製文件夾中創建一個bg.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF"/>
<stroke android:width="3dip" android:color="#B1BCBE" />
<corners android:radius="10dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
祝你好運!
1
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.testing.MainActivity" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="#0000ff"
android:orientation="vertical"
android:layout_weight="1" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="#00ffff"
android:orientation="vertical"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:orientation="vertical"
android:background="#00ff00"
android:layout_gravity="center" />
</FrameLayout>
相關問題
- 1. 將Android屏幕分成兩半等分
- 2. Android-將屏幕分爲兩部分。並使左屏幕不變
- 3. 將屏幕拆分爲兩部分
- 4. 將表格分成兩半
- 5. 分割屏幕一半CSS
- 6. 如何將一副牌分成兩半?
- 7. 將MapView限制爲屏幕的一半
- 8. xml分成兩半
- 9. 將UiImageView水平分割成兩半?
- 10. 在屏幕的右半部分放置背景圖像
- 11. 將NSArray的後半部分與前半部分交錯
- 12. 如何使一個ListFragment僅佔用屏幕的上半部分
- 13. 分裂Lucene索引分爲兩半
- 14. 地圖下半部分和上半部分屏幕在Google地圖v2中爲空
- 15. 如何將有序數據幀拆分爲前半部分和後半部分
- 16. 調整瀏覽器屏幕的兩半
- 17. 在Android屏幕的上半部分顯示當前位置
- 18. 將屏幕分爲兩部分iphone box2d遊戲應用
- 19. Ionic 2:將屏幕拆分爲兩個獨立部分
- 20. 在屏幕的一半部分打開相機 - iPhone
- 21. fullpage.js activepage顯示兩個半部分
- 22. ScrolledComposite垂直分割屏幕,內容顯示在右半部分
- 23. 將ImageView設置爲ScrollView中屏幕高度的一部分
- 24. 如何在Android中將屏幕分成兩部分?
- 25. 在爲TextViews(Android)使用邊框時將屏幕分割爲一半(水平)
- 26. 將ul分成兩半,然後將這兩個部分圍成一個div(動態菜單中的徽標)
- 27. 將UIImage拆分成一半?
- 28. 將Ienumerable分爲兩部分
- 29. 將RelativeLayout分爲兩部分
- 30. 將Linklist分爲兩部分
下部應根據版面內容 –
可以使用在較低的線性佈局 –
但上半部分滾動型也應隨之移動起來是高度伸展。 –