2014-01-29 34 views
0

我認爲這個問題已經問了很多,是的,我一直在這裏找幾個小時,沒有什麼幫助我.. 我可以顯示這張圖片的問題:Android的滾動視圖寬度全屏,也Uri.parse(位置)

http://i.imgur.com/554oMa5.png

對不起,我給的鏈接(我沒有圖像足夠的聲譽)

正如你所看到的,寬度不適合整個屏幕.. 相信我,我試了很多東西來解決它: fill_parent match_parent 比重=填寫 視=真 以及更多......

所以這裏是爲這一刻我的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無法識別這個座標,這裏有什麼問題? 應用程序崩潰。 如果問題出在座標上,那麼如何獲得正確的谷歌地圖座標?

感謝(:

+0

請發佈您的整個佈局xml文件。 – NasaGeek

+0

對不起,我編輯過(:) – hey

回答

0

兩個。你的ScrollView沒有佔用整個屏幕的寬度,因爲你的頂級RelativeLayout有填充設置, d想要你的ScrollView佔用整個屏幕的寬度,看起來好像不會很漂亮...

+0

哇非常感謝!這工作(: 而且我更喜歡ScrollView佔用整個屏幕寬度,在我看來看起來更好。 – hey

0

正如你可以看到here,你必須在前面加上你的位置「地理:」它是一個有效的URI,您應該將問題分解爲單獨的SO職位

+0

它仍然崩潰 – hey

+0

它是否給出了一個異常?當然,它會給出一個異常_什麼是異常._更新你的代碼,以便我們可以看到到底是什麼改變 – NasaGeek

+0

我剛剛編輯過(: – hey