视线被切断了

时间:2014-12-21 19:15:41

标签: android xml android-layout android-view android-xml

我已在可绘制文件夹中将环形状定义为XML文件,如下所示

circle_normal.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="1.9"
android:useLevel="false" >

<solid android:color="#FF0000" />

<size
    android:height="10dp"
    android:width="10dp" />

<stroke
    android:width="1dp"
    android:color="#FFFFFF" />

<padding
    android:bottom="5dp"
    android:left="5dp"
    android:right="5dp"
    android:top="5dp" /></shape>

使用相应形状的布局为 faculty_details

<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:background="@drawable/background"
tools:context=".FacultyDetails" >

<TextView
    android:id="@+id/nameoffaculty"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="94dp"
    android:layout_marginTop="92dp"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="#FFFFFF" />

<View
    android:id="@+id/viewundertextnarrow"
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:layout_alignLeft="@+id/nameoffaculty"
    android:layout_below="@+id/nameoffaculty"
    android:background="#FFFFFF"
    android:paddingBottom="1dp"
    android:paddingTop="1dp" />


<View
    android:id="@+id/viewundertextbold"
    android:layout_width="fill_parent"
    android:layout_height="4dp"
    android:layout_alignLeft="@+id/nameoffaculty"
    android:layout_below="@+id/viewundertextnarrow"
    android:layout_marginTop="2dp"
    android:background="#FFFFFF"
    android:paddingBottom="1dp"
    android:paddingTop="1dp" />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_marginRight="23dp"
    android:layout_toLeftOf="@+id/viewundertextbold"
    android:src="@drawable/phone_icon" />

<TextView
    android:id="@+id/phone_number"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/imageView1"
    android:layout_alignLeft="@+id/viewundertextbold"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="#FFFFFF" />

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_marginLeft="36dp"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:paddingBottom="5dp"
    android:paddingTop="5dp"
    android:layout_toRightOf="@+id/phone_number" >

    <view
        android:id="@+id/viewv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/circle_normal" />
</RelativeLayout></RelativeLayout>

问题是圆圈的两边被切断,如图所示

https://drive.google.com/file/d/0B-JGpeK6rjrBMEVZZU9BaE5EaXc/view?usp=sharing

即使将视图设置为wrap_content,也会选择从上到下的整个视图

https://drive.google.com/file/d/0B-JGpeK6rjrBX29tM19yNlhCMFE/view?usp=sharing

当我尝试运行我的应用时,以下异常处理

12-21 18:20:06.073: E/AndroidRuntime(1478): FATAL EXCEPTION: main
12-21 18:20:06.073: E/AndroidRuntime(1478): Process: com.magnovlabs.contactbook, PID: 1478
12-21 18:20:06.073: E/AndroidRuntime(1478): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.magnovlabs.contactbook/com.magnovlabs.contactbook.FacultyDetails}: android.view.InflateException: Binary XML file line #72: Error inflating class null
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.os.Handler.dispatchMessage(Handler.java:102)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.os.Looper.loop(Looper.java:136)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.app.ActivityThread.main(ActivityThread.java:5017)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at java.lang.reflect.Method.invokeNative(Native Method)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at java.lang.reflect.Method.invoke(Method.java:515)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at dalvik.system.NativeStart.main(Native Method)
12-21 18:20:06.073: E/AndroidRuntime(1478): Caused by: android.view.InflateException: Binary XML file line #72: Error inflating class null
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.app.Activity.setContentView(Activity.java:1929)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at com.magnovlabs.contactbook.FacultyDetails.onCreate(FacultyDetails.java:12)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.app.Activity.performCreate(Activity.java:5231)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
12-21 18:20:06.073: E/AndroidRuntime(1478):     ... 11 more
12-21 18:20:06.073: E/AndroidRuntime(1478): Caused by: java.lang.NullPointerException
12-21 18:20:06.073: E/AndroidRuntime(1478):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
12-21 18:20:06.073: E/AndroidRuntime(1478):     ... 22 more    

java代码只不过是一个没有函数的活动   FacultyDetails

import android.app.Activity;    
import android.os.Bundle;    

public class FacultyDetails extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.faculty_details);
    int value = getIntent().getExtras().getInt("id_fromtable");

}

我不知道该怎么做 我花了几天时间寻找解决方案,但注意到这些问题 所以这是我的三个问题

1 - 视线被切断 2 - 视图填充整个布局 3 - 运行时出错,我不知道id

请帮助谢谢

1 个答案:

答案 0 :(得分:1)

如果您没有任何特定要求将形状用作响铃,则可以将形状更改为椭圆

或者如果您没有任何具体要求将厚度比保持在 1.9 ,您可以将其设置为 2

上述两种情况都应解决斩波问题。