简体   繁体   中英

Android scrollview width full screen, also Uri.parse(location)

i think this question has been asked alot, and yes i have been looking for hours here, nothing really helped me.. I can show the problem with this picture:

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

sorry that i give link( i don't have enough reputation for image)

As you can see, the width doesn't fit the whole screen.. Trust me, i tried so much things to fix it: fill_parent match_parent gravity=fill viewport=true and more..

So here is my XML code for this moment:

 <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>

I also have another problem(not connected to first one):

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();


}

The Uri cannot recognize this coordinates, what is wrong here? The application crashes. If the problem is with coordinates so how to get correct coordinates with google maps?

Thanks (:

As you can see here , you must prepend your location with "geo:" for it to be a valid URI. You should separate your questions into separate SO posts.

Two questions, two answers. Your ScrollView is not taking up the entire width of your screen because your top-level RelativeLayout has padding set. Remove the padding attributes and the ScrollView will fit the entire screen. That said, I have no idea why you'd want your ScrollView to take up the entire screen width. Seems like it wouldn't look very nice...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM