├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── quarkworks │ │ └── roundedframelayout_android │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── quarkworks │ │ │ └── roundedframelayout_android │ │ │ ├── Comment.java │ │ │ ├── CommentLeftCell.java │ │ │ ├── MainActivity.java │ │ │ └── MyAdapter.java │ └── res │ │ ├── drawable │ │ ├── image_1.jpg │ │ ├── image_2.jpeg │ │ ├── image_3.jpg │ │ ├── image_4.jpg │ │ ├── image_5.jpeg │ │ └── placeholder.jpg │ │ ├── layout │ │ ├── activity_main.xml │ │ └── comment_cell_left.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── quarkworks │ └── roundedframelayout_android │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── roundedframelayout ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── quarkworks │ │ └── roundedframelayout │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── quarkworks │ │ │ └── roundedframelayout │ │ │ └── RoundedFrameLayout.java │ └── res │ │ └── values │ │ ├── attrs.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── quarkworks │ └── roundedframelayout │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Quarkworks 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Download 2 | -------- 3 | Use Gradle: 4 | 5 | ```gradle 6 | dependencies { 7 | // RoundedFrameLayout 8 | compile 'com.github.QuarkWorks:RoundedFrameLayout-Android:0.3.7' 9 | } 10 | ``` 11 | How do I use? 12 | ------------------- 13 | Configure radius in layout xml file: 14 | ```xml 15 | 30 | 31 | 32 | 38 | 39 | 40 | ``` 41 | 42 | Or configure radius in code: 43 | ```java 44 | // setCornerRadius() will override four corners 45 | // refreshButtonContainer.setCornerRadius(20); 46 | 47 | refreshButtonContainer.setCornerRadiusTopLeft(10); 48 | refreshButtonContainer.setCornerRadiusTopRight(20); 49 | refreshButtonContainer.setCornerRadiusBottomLeft(20); 50 | refreshButtonContainer.setCornerRadiusBottomRight(10); 51 | 52 | refreshButtonContainer.setClippedBackgroundColor(Color.RED); 53 | refreshButtonContainer.setBorderColor(Color.BLACK); 54 | refreshButtonContainer.setBorderWidth(4); 55 | 56 | // Smooth drawn bound of RoundedFrameLayout when below LOLLIPOP 57 | // Should be close to or same as background color 58 | refreshButtonContainer.setSoftBorderColor(Color.WHITE); 59 | 60 | refreshButtonContainer.requestLayout(); 61 | ``` 62 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.quarkworks.roundedframelayout_android" 8 | minSdkVersion 16 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.3.1' 28 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 29 | compile 'com.android.support:design:25.3.1' 30 | testCompile 'junit:junit:4.12' 31 | compile 'com.android.support:recyclerview-v7:25.3.1' 32 | 33 | compile project(':roundedframelayout') 34 | } 35 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/zekunwang/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/quarkworks/roundedframelayout_android/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.quarkworks.roundedframelayout_android; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.quarkworks.roundedframelayout_android", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/quarkworks/roundedframelayout_android/Comment.java: -------------------------------------------------------------------------------- 1 | package com.quarkworks.roundedframelayout_android; 2 | 3 | /** 4 | * Created by zekunwang on 4/17/17. 5 | */ 6 | 7 | public class Comment { 8 | 9 | String commentId; 10 | String textString; 11 | 12 | public Comment(String commentId, String textString) { 13 | this.commentId = commentId; 14 | this.textString = textString; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/quarkworks/roundedframelayout_android/CommentLeftCell.java: -------------------------------------------------------------------------------- 1 | package com.quarkworks.roundedframelayout_android; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.AttrRes; 5 | import android.support.annotation.DrawableRes; 6 | import android.support.annotation.NonNull; 7 | import android.support.annotation.Nullable; 8 | import android.util.AttributeSet; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.widget.FrameLayout; 12 | import android.widget.ImageView; 13 | import android.widget.TextView; 14 | 15 | /** 16 | * Created by zekunwang on 4/17/17. 17 | */ 18 | 19 | public class CommentLeftCell extends FrameLayout { 20 | 21 | public ImageView profileImageView; 22 | public TextView commentTextView; 23 | public @DrawableRes int imageResId; 24 | 25 | public CommentLeftCell(@NonNull Context context) { 26 | super(context); 27 | initialize(); 28 | } 29 | 30 | public CommentLeftCell(@NonNull Context context, @Nullable AttributeSet attrs) { 31 | super(context, attrs); 32 | initialize(); 33 | } 34 | 35 | public CommentLeftCell(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) { 36 | super(context, attrs, defStyleAttr); 37 | initialize(); 38 | } 39 | 40 | private void initialize() { 41 | LayoutInflater.from(getContext()).inflate(R.layout.comment_cell_left, this); 42 | 43 | this.profileImageView = (ImageView) findViewById(R.id.profile_image_view); 44 | this.commentTextView = (TextView) findViewById(R.id.comment_text_view); 45 | final FrameLayout imageViewContainer = (FrameLayout) findViewById(R.id.profile_image_container); 46 | 47 | 48 | 49 | imageViewContainer.addOnLayoutChangeListener(new OnLayoutChangeListener() { 50 | @Override 51 | public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { 52 | imageViewContainer.requestLayout(); 53 | } 54 | }); 55 | 56 | profileImageView.addOnLayoutChangeListener(new OnLayoutChangeListener() { 57 | @Override 58 | public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { 59 | 60 | profileImageView.setImageResource(imageResId); 61 | } 62 | }); 63 | } 64 | 65 | public void setViewData(Comment comment) { 66 | int imageId = comment.commentId.hashCode() % 5 + 1; 67 | imageResId = R.drawable.image_1; 68 | 69 | switch (imageId) { 70 | case 1: 71 | imageResId = R.drawable.image_1; 72 | break; 73 | case 2: 74 | imageResId = R.drawable.image_2; 75 | break; 76 | case 3: 77 | imageResId = R.drawable.image_3; 78 | break; 79 | case 4: 80 | imageResId = R.drawable.image_4; 81 | break; 82 | case 5: 83 | imageResId = R.drawable.image_5; 84 | break; 85 | } 86 | 87 | profileImageView.setImageResource(imageResId); 88 | commentTextView.setText(comment.textString); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /app/src/main/java/com/quarkworks/roundedframelayout_android/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.quarkworks.roundedframelayout_android; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.LinearLayoutManager; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.view.View; 9 | import android.widget.Button; 10 | import android.widget.EditText; 11 | 12 | import com.quarkworks.roundedframelayout.RoundedFrameLayout; 13 | 14 | import java.util.ArrayList; 15 | import java.util.Random; 16 | import java.util.UUID; 17 | 18 | public class MainActivity extends AppCompatActivity { 19 | 20 | EditText inputEditText; 21 | Button leftButton; 22 | View refreshButton; 23 | RoundedFrameLayout refreshButtonContainer; 24 | RecyclerView recyclerView; 25 | 26 | MyAdapter adapter; 27 | ArrayList comments; 28 | 29 | Random random = new Random(); 30 | boolean isFree = true; 31 | 32 | @Override 33 | protected void onCreate(Bundle savedInstanceState) { 34 | super.onCreate(savedInstanceState); 35 | setContentView(R.layout.activity_main); 36 | 37 | View composeContainer = findViewById(R.id.compost_container); 38 | inputEditText = (EditText) composeContainer.findViewById(R.id.input_edit_text); 39 | leftButton = (Button) composeContainer.findViewById(R.id.left_button); 40 | refreshButton = composeContainer.findViewById(R.id.refresh_button); 41 | refreshButtonContainer = (RoundedFrameLayout) findViewById(R.id.refresh_button_container); 42 | 43 | leftButton.setOnClickListener(new View.OnClickListener() { 44 | @Override 45 | public void onClick(View v) { 46 | comments.add(new Comment(UUID.randomUUID().toString(), 47 | inputEditText.getText().toString().trim())); 48 | adapter.notifyDataSetChanged(); 49 | 50 | recyclerView.scrollToPosition(adapter.getItemCount() - 1); 51 | } 52 | }); 53 | 54 | refreshButton.setOnClickListener(new View.OnClickListener() { 55 | @Override 56 | public void onClick(View v) { 57 | adapter.notifyDataSetChanged(); 58 | 59 | if (isFree) { 60 | refreshButtonContainer.setCornerRadiusTopLeft(random.nextInt(31)); 61 | refreshButtonContainer.setCornerRadiusTopRight(random.nextInt(31)); 62 | refreshButtonContainer.setCornerRadiusBottomLeft(random.nextInt(31)); 63 | refreshButtonContainer.setCornerRadiusBottomRight(random.nextInt(31)); 64 | } else { 65 | //setCornerRadius() will set to four corners 66 | refreshButtonContainer.setCornerRadius(random.nextInt(31)); 67 | } 68 | 69 | isFree = !isFree; 70 | 71 | refreshButtonContainer.setClippedBackgroundColor(Color.RED); 72 | refreshButtonContainer.setBorderColor(Color.BLACK); 73 | refreshButtonContainer.setBorderWidth(4); 74 | 75 | // Smooth drawn bound of RoundedFrameLayout when below LOLLIPOP 76 | // Should be close to or same as background color 77 | refreshButtonContainer.setSoftBorderColor(Color.WHITE); 78 | 79 | refreshButtonContainer.requestLayout(); 80 | } 81 | }); 82 | 83 | recyclerView = (RecyclerView) findViewById(R.id.recycler_view); 84 | comments = new ArrayList<>(); 85 | Random rand = new Random(); 86 | for (int i = 0; i < 20; i++) { 87 | String id = UUID.randomUUID().toString(); 88 | String message = id; 89 | for (int j = 0; j < rand.nextInt(8); j++) { 90 | message += id; 91 | } 92 | 93 | comments.add(new Comment(id, message)); 94 | } 95 | 96 | adapter = new MyAdapter(comments); 97 | LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false); 98 | recyclerView.setAdapter(adapter); 99 | recyclerView.setLayoutManager(layoutManager); 100 | 101 | recyclerView.scrollToPosition(adapter.getItemCount() - 1); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /app/src/main/java/com/quarkworks/roundedframelayout_android/MyAdapter.java: -------------------------------------------------------------------------------- 1 | package com.quarkworks.roundedframelayout_android; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.util.Log; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | 8 | import java.util.ArrayList; 9 | 10 | /** 11 | * Created by zekunwang on 4/17/17. 12 | */ 13 | 14 | public class MyAdapter extends RecyclerView.Adapter { 15 | 16 | ArrayList comments; 17 | 18 | public MyAdapter(ArrayList comments) { 19 | this.comments = comments; 20 | } 21 | 22 | @Override 23 | public int getItemViewType(int position) { 24 | return super.getItemViewType(position); 25 | } 26 | 27 | @Override 28 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 29 | return new RecyclerView.ViewHolder(new CommentLeftCell(parent.getContext())) {}; 30 | } 31 | 32 | @Override 33 | public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) { 34 | CommentLeftCell leftCell = (CommentLeftCell) holder.itemView; 35 | leftCell.setViewData(comments.get(position)); 36 | 37 | leftCell.setOnClickListener(new View.OnClickListener() { 38 | @Override 39 | public void onClick(View v) { 40 | Log.e("item click", "item click: " + position); 41 | notifyItemChanged(position); 42 | } 43 | }); 44 | } 45 | 46 | @Override 47 | public int getItemCount() { 48 | return comments.size(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/image_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkWorks/RoundedFrameLayout-Android/f9ac3fdd071d4961bc4402dbca44d94d79d6fbb0/app/src/main/res/drawable/image_1.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/image_2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkWorks/RoundedFrameLayout-Android/f9ac3fdd071d4961bc4402dbca44d94d79d6fbb0/app/src/main/res/drawable/image_2.jpeg -------------------------------------------------------------------------------- /app/src/main/res/drawable/image_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkWorks/RoundedFrameLayout-Android/f9ac3fdd071d4961bc4402dbca44d94d79d6fbb0/app/src/main/res/drawable/image_3.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/image_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkWorks/RoundedFrameLayout-Android/f9ac3fdd071d4961bc4402dbca44d94d79d6fbb0/app/src/main/res/drawable/image_4.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/image_5.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkWorks/RoundedFrameLayout-Android/f9ac3fdd071d4961bc4402dbca44d94d79d6fbb0/app/src/main/res/drawable/image_5.jpeg -------------------------------------------------------------------------------- /app/src/main/res/drawable/placeholder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkWorks/RoundedFrameLayout-Android/f9ac3fdd071d4961bc4402dbca44d94d79d6fbb0/app/src/main/res/drawable/placeholder.jpg -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 24 | 25 |