Reputation: 19
I've defined a ring shape as XML file in the drawable folder as shown below
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>
the layout in which the corresponding shape used is 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>
the problem is the sides of the circle is getting chopped off as shown in the image
https://drive.google.com/file/d/0B-JGpeK6rjrBMEVZZU9BaE5EaXc/view?usp=sharing
also even if the the view is set to wrap_content the whole view from the top to bottom is being selected
https://drive.google.com/file/d/0B-JGpeK6rjrBX29tM19yNlhCMFE/view?usp=sharing
when i try to run my app the following exception popes up
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
the java code is nothing but jus an activity with no functions 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");
}
i have no idea what to do i have spend days searching for solutions but noting describes these problems so here are my three problems
1--sides of view getting chopped off 2--view fills over the entire layout 3--error on running that i have no idea what id
please help THANKS
Upvotes: 0
Views: 67
Reputation: 214
If you do not have any specific requirement to use the shape as ring, you can change the shape to oval
Or if you do not have any specific requirement to keep the thickness ratio to 1.9, you can set it to 2
Both the above scenarios should solve the chopping problem.
Upvotes: 1