[英]Android scrollview width full screen, also Uri.parse(location)
我認為這個問題已經問了很多,是的,我一直在這里找幾個小時,沒有什么真正的幫助我。.我可以用這張照片來顯示問題:
http://i.imgur.com/554oMa5.png
抱歉,我給出了鏈接(我在圖像方面沒有足夠的聲譽)
如您所見,寬度不適合整個屏幕。相信我,我做了很多事情來解決它:fill_parent match_parentgravity = fill viewport = true等。
所以這是我目前的XML代碼:
<RelativeLayout 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#000000"
tools:context=".Succes" >
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="@+id/google"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:onClick="onClickGoogle"
android:text="Go google" />
<View
android:layout_width="fill_parent"
android:layout_height="30dp"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:onClick="onClickSudan"
android:text="Go to Sudan!" />
<View
android:layout_width="fill_parent"
android:layout_height="30dp"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:onClick="onClickAwesome"
android:text="Awesome button" />
<View
android:layout_width="fill_parent"
android:layout_height="30dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="30dp"
android:gravity="center"
android:text="Rate me!"
/>
<RatingBar
android:id="@+id/lol2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numStars="5"
android:gravity="center" />
<View
android:layout_width="fill_parent"
android:layout_height="30dp"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:onClick="onClickHai"
android:text="Hai" />
<View
android:layout_width="fill_parent"
android:layout_height="30dp"
/>
<SeekBar
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<View
android:layout_width="fill_parent"
android:layout_height="30dp"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:onClick="onClickSuper"
android:text="Super button" />
<View
android:layout_width="fill_parent"
android:layout_height="30dp"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:onClick="onClickOut"
android:text="Go back" />
</LinearLayout>
</ScrollView>
我也有另一個問題(未連接到第一個):
public void onClickSudan(View view)
{
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle("GO TO SUDAN?");
dialog.setMessage("Are you really sure go to Sudan?" +
" By pressing yes you will not have the ability to come back!" +
" Please think good before clicking yes(think really good).");
dialog.setCancelable(true);
dialog.setPositiveButton("yes",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id)
{
//if clicked okay, go to there ;o
Uri location = Uri.parse("geo:18.130191,31.683355");
Intent start = new Intent(Intent.ACTION_VIEW, location);
startActivity(start);
}
});
dialog.setNegativeButton("No.", null);
AlertDialog dialog2 = dialog.create();
dialog2.show();
}
Uri無法識別此坐標,這是怎么了? 應用程序崩潰。 如果問題出在坐標上,那么如何使用Google地圖獲取正確的坐標?
謝謝 (:
如您在此處看到的那樣,您必須在位置前面加上“ geo:”,以使其成為有效的URI。 您應該將問題分成單獨的SO帖子。
兩個問題,兩個答案。 ScrollView
不會占用屏幕的整個寬度,因為頂級RelativeLayout
設置了填充。 刪除padding
屬性,然后ScrollView
將適合整個屏幕。 就是說,我不知道您為什么要讓ScrollView
占據整個屏幕寬度。 好像不太好看...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.