繁体   English   中英

Android scrollview宽度全屏显示,也是Uri.parse(location)

[英]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.

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