2014-01-29 7 views
0

Я думаю, что этот вопрос задан много, и да, я искал здесь несколько часов, ничего не помогло мне. Я могу показать проблему с этим изображением :Android scrollview width full screen, также Uri.parse (location)

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 не может распознать эти координаты, что здесь не так? Приложение аварийно завершает работу. Если проблема связана с координатами, как получить правильные координаты с картами Google?

спасибо (:

+0

Пожалуйста, разместите весь файл xml. – NasaGeek

+0

Да, извините, я отредактировал (: – hey

ответ

0

Two.. вопросы, два ответа. Ваш ScrollView не занимает всю ширину экрана, потому что ваш верхний уровень RelativeLayout имеет набор дополнений. Удалите атрибуты padding, и ScrollView будет соответствовать всему экрану. Тем не менее, я понятия не имею, d хочу, чтобы ваш ScrollView занимал всю ширину экрана. Кажется, это выглядело бы не очень хорошо ...

+0

Wow thanks alot !! Это сработало (: И я предпочитаю ScrollView принимать всю ширину экрана, выглядит лучше, на мой взгляд. – hey

0

Как вы можете видеть here, вы должны указать свое местоположение с «гео:» для того, чтобы быть действительной URI Вы должны разделить ваши вопросы на отдельные SO постов

+0

Он по-прежнему сбой. – hey

+0

Вызывает ли это исключение? Исправлено, что, конечно, оно дает исключение. _Что такое исключение._ Также обновите свой код, чтобы мы могли точно видеть, какие изменения вы меняете – NasaGeek

+0

Я отредактировал сейчас (: – hey