3

enter image description here안드로이드 - fill_parent의 텍스트 뷰에 의해 중복 둥근 선형 레이아웃 코너

이것은 내가 내 레이아웃의 상단에 필요하다

enter image description here

이 실제로 무엇을 가지고

내가 지금 계산하지 않고있는 간단한 옵션이 있습니다. 이미 처음의 LinearLayout 아이로 드로어 블을 이동하는 것을 시도했다

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/home_root" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/rounded_layout" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/filter_title" 
      android:background="@android:color/black" 
      android:textColor="@android:color/white" 
      android:padding="10dp" 
      android:textSize="20sp" /> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:padding="15dp" > 

      <Spinner 
       android:id="@+id/sp_intorno_a_me_proximity" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dp" 
       android:spinnerMode="dialog" /> 
      . 
      . 
      . 
      <EditText 
       android:id="@+id/et_intorno_a_me_username" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dp" 
       android:textSize="20sp" 
       android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" 
       android:hint="@string/agentNumber" /> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:layout_marginTop="20dp" 
       android:layout_marginBottom="10dp" 
       android:weightSum="1" > 

       <Button 
        android:id="@+id/btn_intorno_a_me_close_search" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="0.5" 
        android:text="@string/annulla" 
        style="@style/HelianButtonRed" 
        android:textColor="@android:color/white" /> 

       <Button 
        android:id="@+id/btn_intorno_a_me_search" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="0.5" 
        android:text="@string/find" 
        style="@style/HelianButtonGreen" /> 
      </LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 

</ScrollView> 

둥근 모서리

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="#E9E9E9"/> 
    <stroke android:width="4dip" android:color="#B1BCBE" /> 
    <corners android:radius="10dip"/> 
    <padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" /> 
</shape> 

레이아웃에 대한

드로어 블.

둥근 모서리가 보이지 않도록 텍스트보기를 방지하려면 어떻게합니까?

+0

두 번째 LinearLayout에서 제목 TextView를 선언하지 않는 이유는 무엇입니까? 이렇게하면 textView 배경이 둥근 모서리와 겹치지 않게됩니다. – Manishika

+0

결과는 ** android : padding = "15dp"**로 인해 채워집니다. 두 번째 선형 레이아웃. 하나의보기에서 패딩을 피할 수 있습니까? –

답변

2

TextView에서 이와 같은 방법으로 시도해보십시오. 는 다음과 같은 데이터

Manishika의 도움으로
<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="#000000"/> 
    <stroke android:width="4dip" android:color="#B1BCBE" /> 
    <corners 
     android:topLeftRadius="10dip" 
     android:topRightRadius="10dip" 
     android:bottomLeftRadius="0dip" 
     android:bottomRightRadius="0dip" 

     /> 
    <padding android:left="0dip" android:top="0dip" android:right="0dip"     
     android:bottom="0dip" /> 

</shape> 
+0

아직 시도하지는 않았지만이 해결 방법이 효과가있을 것이라고 확신합니다. 그러나 반경과 색상을 두 번 복제해야하는 더 멋진 솔루션을 원합니다 (하나는 레이아웃 그리기 용이고 다른 하나는 버튼 용입니다). 무승부). 일반화하고 싶습니다 ... 어쨌든 나에게 사람을 주셔서 감사합니다! –

+0

아니요 실제로 parentLayout에 패딩을 지정하면 하나의보기에 패딩을 제거 할 수 없습니다. 그러나 할 수있는 일은 패딩없이 TextView를 LinearLayout에 배치하고 textView의 LinearLayout과 LinearLayout2를 하나의 LinearLayout에 배치하고이 LinearLayout에 배경을 지정하는 것입니다. 이 방법은 당신의 TextView가 패딩을 가지고 있지 않을 것입니다. – Manishika

+0

나는 이것이 나쁜 습관이라는 것을 알고 있습니다. 그러나 당신은 시도해야합니다. – Manishika

3

와 텍스트 뷰를위한 새로운 그릴 수 .XML 만들기 (나는 당신의 대답까지 투표 [나를 위해 동일한 작업을 수행을! :)]) 내 문제의 해결책을 게시하도록하겠습니다 ! 이 부모 둥근 모서리 스타일로

:

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="#E9E9E9"/> 
    <stroke android:width="4dip" android:color="#B1BCBE" /> 
    <corners android:radius="10dip"/> 
    <padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" /> 
</shape> 

우리는 텍스트 뷰 (또는 당신이 필요로하는 모든보기)에 특정 드로어 블을 연결해야합니다. 여기

트릭위한 그리기이다

I 2 D에게

<corners 
     android:topLeftRadius="8dip" 
     android:topRightRadius="8dip" 
     android:bottomLeftRadius="0dip" 
     android:bottomRightRadius="0dip" /> 
</shape> 

KEEP 염두에 감산!

그래픽 레이아웃 (미리보기)는 것이다 하지 올바른 라운딩을 보여줍니다! 장치 (또는 장치가없는 경우에는 에뮬레이터)에서 테스트해야합니다.